Express (Distributed operating systems), v8.0 > Secure applications and their environment > Authenticate users > Select a registry or repository > Manage realms in a federated repository > Virtual member manager > Develop with virtual member manager > Integrate virtual member manager into the application > Program tasks


Create a property type and adding it to an existing entity type

We can use the sample data graphs and code snippet provided here to create a property type, age, and add it to an existing entity type, PersonAccount.


Input data graph

<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:sdo="commonj.sdo"
    xmlns:wim="//www.ibm.com/websphere/wim">
<wim:Root>
<wim:schema>
<wim:propertySchema nsPrefix="yourext" nsURI="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/  ://www.yourco.com/wim/yourext"
          dataType="Int" multiValued="false" propertyName="age">  
<wim:applicableEntityTypeNames>PersonAccount
</wim:applicableEntityTypeNames>
</wim:propertySchema>
</wim:schema>
</wim:Root>
</sdo:datagraph> 


Output data graph

The returned data graph contains the IDs of the repositories that support this new property type.
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:sdo="commonj.sdo"
    xmlns:wim="//www.ibm.com/websphere/wim">
<wim:Root>
<wim:schema>
<wim:propertySchema nsPrefix="yourext" nsURI="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/  ://www.yourco.com/wim/yourext"
          dataType="Int" multiValued="false" propertyName="age">  
<wim:repositoryIds>LDAP1
</wim:repositoryIds>  
<wim:applicableEntityTypeNames>PersonAccount
</wim:applicableEntityTypeNames>
</wim:propertySchema>
</wim:schema>
</wim:Root>
</sdo:datagraph> 


wimxmlextension.xml file

After schema is created, the wimxmlextension.xml looks like this snippet:
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:sdo="commonj.sdo"
    xmlns:wim="//www.ibm.com/websphere/wim">
<wim:schema>
<wim:propertySchema nsPrefix="yourext" nsURI="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/  ://www.yourco.com/wim/yourext"
        dataType="Int" multiValued="false" propertyName="age">
<wim:applicableEntityTypeNames>PersonAccount
</wim:applicableEntityTypeNames>
</wim:propertySchema>
</wim:schema>
</sdo:datagraph> 

For more information about using the propertySchema and extensionPropertySchema data objects, see the section, Extend property schema in the topic, Program prerequisites. Also read about Configure a property extension repository in a federated repository in the WebSphere Application Server information center.


Sample code

Use the following code to create a property type, age and to add it to an existing entity type PersonAccount.

private static String dynaextURI = "//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/  ://www.yourco.com/wim/yourext";
private static String dynaextPrefix = "yourext";
String newPropName = "age";

    try {

        System.out.println("\nCLIENT: Create new property type
                and add it to existing entity type PersonAccount...");
        DataObject root = service.createRootDataObject();
        DataObject dynaSchemaDO = root.createDataObject(SchemaConstants.DO_SCHEMA);

        // create new property
DataObject propSchemaDO = dynaSchemaDO.createDataObject(SchemaConstants.DO_EXTENSION_PROPERTY_SCHEMA);
        propSchemaDO.set(SchemaConstants.PROP_NS_URI, dynaextURI);
        propSchemaDO.set(SchemaConstants.PROP_NS_PREFIX, dynaextPrefix);

        propSchemaDO.set(SchemaConstants.PROP_PROPERTY_NAME, newPropName);
        propSchemaDO.setBoolean(SchemaConstants.PROP_MULTI_VALUED, false);
        propSchemaDO.set(SchemaConstants.PROP_DATA_TYPE, SchemaConstants.DATA_TYPE_INT);
        List applicableEntityTypes = propSchemaDO.getList(SchemaConstants.PROP_APPLICABLE_ENTITY_TYPE_NAMES);
        applicableEntityTypes.add("PersonAccount");

        SDOUtils.printDataGraph(INPUT_DATAGRAPH, root);
        service.createSchema(root);
        System.out.println("\nCLIENT: new property type is created.");
    }
    catch (Exception e) {
        printException(e);
    }

Parent topic: Program tasks



+

Search Tips   |   Advanced Search