|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: EMF object serialization into xml [message #545055 is a reply to message #545032] |
Tue, 06 July 2010 13:53 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugur,
You need to enter true or false in the Properties view for the Default
Value Literal feature for the EAttribute of your model. It should be there.
Ugur Kocak wrote:
> Hi Ed,
> simple question:
> do I have to type false/true in the Value field of the attribute.
> I ask because there isn't any given value false/true for the Default
> Value Literal in the Properties view.
>
> Best regards
> Ugur
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: EMF object serialization into xml [message #622846 is a reply to message #531970] |
Thu, 06 May 2010 16:30 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugur,
Comments below.
Ugur Kocak wrote:
> Hi Cyril,
>
> I have an additional problem:
> I have more than ComputerResources objects for example:
> 1) PrinterResources objects which have an attribute of type boolean (I
> can't see attributes with value=true)
EMF can serialize any instance to XML.
> 2nd) Group objects which have associations in my ecore diagram
> hasMember and memberOf . These associations are handled as attributres
> with values, too.
How so and by whom?
> Some of this attribute values are numbers and not String names like
> in System.out
I don't follow.
>
> Do you know the reason for these dilemma :?
What's the dilemma?
> Thank you again.
You just need to put all your objects in one or more resources and they
should just serialize. What aspect of that isn't working well for you?
>
> Br Ugur
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EMF object serialization into xml [message #622867 is a reply to message #622865] |
Mon, 10 May 2010 06:30 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugar,
Comments below.
Ugur Kocak wrote:
> Hi Ed,
>
> my question concerns the following case: I have an ecore model with
> classes: Group, ComputerResources, PrinterResources...... The class
> Group has two recursive associations hasMember and MemberOf. Then I
> have the 2 methods getHasMember() and getMemberOf(). I extract the
> values for all of the attributes of the objects from Active Directory
> with LDAP/JNDI. There are two attributes member and memberOf in the
> Acitve Directory. I create an object for every Group. A group object
> has "member" attribute (values are all Group objects which are members
> of this group) and "memberOf "attribute (values are all Groups objects
> inversely contain this Group object ). My problem first Problem is
> that if i create my .xmi file then all of the attribute values for
> "member" and "memberOf" are integer id's like "/652". But I have set
> the attribute "distinguishedName" a String value as identification for
> the Group attribute's.
You can specialize a resource's getURIFragmentRootSegment and
getEObjectForURIFragmentRootSegment methods.
>
> My 2nd porblem is that all boolean attributes with a value "true" are
> hidden in the xmi.file .
Yes, features for which eIsSet if false don't need to be serialized.
> That means that I can't see for some object's that they have such an
> attribute.
Try OPTION_KEEP_DEFAULT_CONTENT.
>
> Could you explain me why it's so.
>
> Thank you in advance.
>
> Best regards
> Ugur Kocak
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: EMF object serialization into xml [message #622876 is a reply to message #622869] |
Tue, 11 May 2010 11:14 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugar,
Did you also set an explicit default on the feature itself? Except for
primitive types, all features implicitly default to null. For
primitives, they default to the same value as the implicit Java
default. You'll need to set an explicit default if you want something
serialized with that option.
Ugur Kocak wrote:
> Hi Ed,
>
> I have the following Code, but I can't see any attributes with boolean
> value "true" in my .xmi file.
>
> public class SerializationUtility {
>
> public void serialize() throws IOException {
>
> ResourceSet rs = new ResourceSetImpl();
>
> XMIResourceImpl myXMResourceImpl = new XMIResourceImpl();
> myXMResourceImpl.getDefaultSaveOptions().put(
> XMIResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
>
> // Register the base XML resource factory implementation in the
> local resource factory registry.
> rs.getResourceFactoryRegistry().getExtensionToFactoryMap().p ut(
> "xmi", new XMIResourceFactoryImpl());
> URI fileURI = URI.createFileURI( "ResourcesFZI.xmi");
>
> Resource resource = rs.createResource( fileURI);
> // add the root objects to the resource
> Iterator<ComputerResources> itr =
> ComputerCollectionGenerator.computerResoucres.iterator();
> while ( itr.hasNext()) {
> ComputerResources next = itr.next();
> resource.getContents().add( next);
> }
>
> Iterator<PrinterResources> itr2 =
> PrinterCollectionGenerator.printerResources.iterator();
> while ( itr2.hasNext()) {
> PrinterResources next = itr2.next();
> resource.getContents().add( next);
> }
>
> Iterator<RoomResources> itr3 =
> RoomCollectionGenerator.roomResoucres.iterator();
> while ( itr3.hasNext()) {
> RoomResources next = itr3.next();
> resource.getContents().add( next);
> }
>
> Collection<Group> groups =
> GroupCollectionGenerator.groupMap.values();
> Iterator<Group> itr4 = groups.iterator();
> while ( itr4.hasNext()) {
> Group next = itr4.next();
> resource.getContents().add( next);
> }
>
> Iterator<ExternerUser> itr5 =
> ExternerUserCollectionGenerator.externeUser.iterator();
> while ( itr5.hasNext()) {
> ExternerUser next = itr5.next();
> resource.getContents().add( next);
> }
>
> Collection<Studenten> studenten =
> UserCollectionGenerator.studentMap.values();
> Iterator<Studenten> itr6 = studenten.iterator();
> while ( itr6.hasNext()) {
> Studenten next = itr6.next();
> resource.getContents().add( next);
> }
>
> Collection<Mitarbeiter> mitarbeiter =
> UserCollectionGenerator.mitarbeiterMap.values();
> Iterator<Mitarbeiter> itr7 = mitarbeiter.iterator();
> while ( itr7.hasNext()) {
> Mitarbeiter next = itr7.next();
> resource.getContents().add( next);
> }
>
> Collection<Manager> manager =
> UserCollectionGenerator.managerMap.values();
> Iterator<Manager> itr8 = manager.iterator();
> while ( itr8.hasNext()) {
> Manager next = itr8.next();
> resource.getContents().add( next);
> }
>
> Collection<Vorstand> vorstand =
> UserCollectionGenerator.vorstandMap.values();
> Iterator<Vorstand> itr9 = vorstand.iterator();
> while ( itr9.hasNext()) {
> Vorstand next = itr9.next();
> resource.getContents().add( next);
> }
>
> resource.save( null);
>
> }
> }
>
> Maybe do you know where's the problem?
> You see I have tried it with "OPTION_KEEP_DEFAULT_CONTENT" = false and
> true, but I can't see anything.
>
> Best regards
> U.Kocak
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EMF object serialization into xml [message #622882 is a reply to message #622881] |
Tue, 11 May 2010 13:27 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugar,
You do that in the properties view in the editor by specifying either
the string false or true for the Default Value Literal.
Ugur Kocak wrote:
> Hi Ed, you're right I didn't set any explicit default on the feature.
> How can I do this. Which methods and classes are responsible to set an
> explicit default on the feature.
>
> Best regards
> Ugur
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EMF object serialization into xml [message #623042 is a reply to message #623041] |
Tue, 06 July 2010 13:53 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Ugur,
You need to enter true or false in the Properties view for the Default
Value Literal feature for the EAttribute of your model. It should be there.
Ugur Kocak wrote:
> Hi Ed,
> simple question:
> do I have to type false/true in the Value field of the attribute.
> I ask because there isn't any given value false/true for the Default
> Value Literal in the Properties view.
>
> Best regards
> Ugur
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.06072 seconds