Search in sources :

Example 96 with SDOType

use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.

the class OpenContentPropertiesByNameTestCases method testDefineOpenContentPropertyNullUri.

public void testDefineOpenContentPropertyNullUri() {
    SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
    DataObject propDO = dataFactory.create(propertyType);
    propDO.set("name", "testProp");
    propDO.set("type", SDOConstants.SDO_STRING);
    typeHelper.defineOpenContentProperty(null, propDO);
    Property typeProp = typeHelper.getOpenContentProperty("my.uri", "testProp");
    assertNull(typeProp);
    Property xsdProp = xsdHelper.getGlobalProperty("my.uri", "testProp", true);
    assertNull(xsdProp);
    xsdProp = xsdHelper.getGlobalProperty("my.uri", "testProp", false);
    assertNull(xsdProp);
}
Also used : DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType) Property(commonj.sdo.Property)

Example 97 with SDOType

use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.

the class SDOTypeHelperAppInfoTestCases method testAppInfoElements.

/**
 * Tests setting appinfo elements on a Type and Property via
 * dataObject.set(Property, Object) API.
 *
 * Positive test.
 */
public void testAppInfoElements() {
    List<Element> aieList = new ArrayList<Element>();
    aieList.add(aiElement);
    List<Element> aiePropList = new ArrayList<Element>();
    aiePropList.add(aiElementProp);
    // create the data object
    SDODataObject dataObject = (SDODataObject) dataFactory.create(sdoTypeType);
    dataObject.set(NAME, MYDO);
    dataObject.set(URI, MYURI);
    dataObject.set(SDOConstants.APPINFO_PROPERTY, aieList);
    // create a property
    SDODataObject prop = (SDODataObject) dataObject.createDataObject(PROPERTY);
    prop.set(NAME, MYPROP);
    prop.set(TYPE, SDOConstants.SDO_STRING);
    prop.set(SDOConstants.APPINFO_PROPERTY, aiePropList);
    // create the type
    SDOType newType = (SDOType) typeHelper.define(dataObject);
    // ======
    // DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
    // List<Object> types = new ArrayList<Object>();
    // types.add(newType);
    // String generatedSchema = ((SDOXSDHelper)xsdHelper).generate(types, resolver);
    // System.out.println(generatedSchema);
    // ======
    // validate that AppInfoElements were handled correctly on Type and Property
    // Type
    assertNotNull("Type [newType] is null", newType);
    assertTrue("Type does not have AppInfoElements set as expected", newType.getAppInfoElements() != null);
    assertTrue("Expected AppInfoElements list of size [1] on Type, but was [" + newType.getAppInfoElements().size() + "]", newType.getAppInfoElements().size() == 1);
    String val = ((Element) newType.getAppInfoElements().get(0)).getAttribute(SDOConstants.APPINFO_SOURCE_ATTRIBUTE);
    assertNotNull("AppInfoElement source on Type is empty/null", val != null && val.length() > 0);
    assertTrue("Expected AppInfoElement source [" + TYPE_APP_INFO + "] on Type but was [" + val + "]", val.equals(TYPE_APP_INFO));
    String appInfoString = xsdHelper.getAppinfo(newType, TYPE_APP_INFO);
    assertEquals("Expected getAppInfo() to return [" + TYPE_APP_INFO_STRING + "] but was [" + appInfoString + "]", TYPE_APP_INFO_STRING, appInfoString);
    // Property
    SDOProperty myProp = newType.getProperty(MYPROP);
    assertNotNull("Property [myProperty] is null", myProp);
    assertTrue("Property does not have AppInfoElements set as expected", myProp.getAppInfoElements() != null);
    assertTrue("Expected AppInfoElements list of size [1] on Property, but was [" + myProp.getAppInfoElements().size() + "]", myProp.getAppInfoElements().size() == 1);
    val = ((Element) myProp.getAppInfoElements().get(0)).getAttribute(SDOConstants.APPINFO_SOURCE_ATTRIBUTE);
    assertNotNull("AppInfoElement source on Property is empty/null", val != null && val.length() > 0);
    assertTrue("Expected AppInfoElement source [" + PROPERTY_APP_INFO + "] on Property but was [" + val + "]", val.equals(PROPERTY_APP_INFO));
    appInfoString = xsdHelper.getAppinfo(myProp, PROPERTY_APP_INFO);
    assertEquals("Expected getAppInfo() to return [" + PROPERTY_APP_INFO_STRING + "] but was [" + appInfoString + "]", PROPERTY_APP_INFO_STRING, appInfoString);
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 98 with SDOType

use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.

the class LoadAndSaveWithImportsTestCases method registerTypes.

@Override
public void registerTypes() {
    Type intType = typeHelper.getType("commonj.sdo", "Int");
    Type stringType = typeHelper.getType("commonj.sdo", "String");
    Type decimalType = typeHelper.getType("commonj.sdo", "Decimal");
    Type dateType = typeHelper.getType("commonj.sdo", "Date");
    Type booleanType = typeHelper.getType("commonj.sdo", "Boolean");
    SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
    DataObject nameType = defineType("http://www.globalcompany.com/ns/order", "Name");
    addProperty(nameType, "First", stringType, false, false, true);
    addProperty(nameType, "Last", stringType, false, false, true);
    Type nameSDOType = typeHelper.define(nameType);
    DataObject itemType = defineType("http://www.globalcompany.com/ns/order", "ItemType");
    addProperty(itemType, "ProductName", stringType, false, false, true);
    addProperty(itemType, "itemType", stringType, false, false, true);
    addProperty(itemType, "partnum", stringType, false, false, true);
    addProperty(itemType, "price", decimalType, false, false, true);
    addProperty(itemType, "Quantity", decimalType, false, false, true);
    Type itemSDOType = typeHelper.define(itemType);
    DataObject orderItemsType = defineType("http://www.globalcompany.com/ns/order", "OrderItemsType");
    DataObject itemsProp = addProperty(orderItemsType, "Item", itemSDOType, true, true, true);
    Type orderItemsSDOType = typeHelper.define(orderItemsType);
    DataObject addressType = defineType("http://www.globalcompany.com/ns/order", "Address");
    addProperty(addressType, "Street", stringType, false, false, true);
    addProperty(addressType, "City", stringType, false, false, true);
    addProperty(addressType, "State", stringType, false, false, true);
    addProperty(addressType, "Zip", stringType, false, false, true);
    addProperty(addressType, "Country", stringType, false, false, true);
    Type addressSDOType = typeHelper.define(addressType);
    DataObject usAddressType = defineType("http://www.globalcompany.com/ns/order", "USAddress");
    addProperty(usAddressType, "Name", nameSDOType, true, false, true);
    addProperty(usAddressType, "Address", addressSDOType, true, false, true);
    Type usAddressSDOType = typeHelper.define(usAddressType);
    DataObject contactType = defineType("http://www.globalcompany.com/ns/order", "ContactType");
    addProperty(contactType, "PhoneNumber", stringType, false, false, true);
    addProperty(contactType, "EmailAddress", stringType, false, false, true);
    Type contactSDOType = typeHelper.define(contactType);
    DataObject supplierInfoType = defineType("http://www.globalcompany.com/ns/order", "SupplierInfoType");
    addProperty(supplierInfoType, "SupplierPrice", decimalType, false, false, true);
    addProperty(supplierInfoType, "SupplierName", stringType, false, false, true);
    Type supplierInfoSDOType = typeHelper.define(supplierInfoType);
    DataObject orderInfoType = defineType("http://www.globalcompany.com/ns/order", "OrderInfoType");
    // addProperty(orderInfoType, "OrderDate", dateType, false, false, true);
    addProperty(orderInfoType, "OrderDate", SDOConstants.SDO_DATETIME, false, false, true);
    addProperty(orderInfoType, "OrderPrice", decimalType, false, false, true);
    addProperty(orderInfoType, "OrderStatus", stringType, false, false, true);
    addProperty(orderInfoType, "OrderComments", stringType, false, false, true);
    addProperty(orderInfoType, "ApprovalRequired", booleanType, false, false, true);
    // DataObject orderPoProp = addProperty(orderInfoType, "PurchaseOrder", poSDOType);
    // orderPoProp.set("containment", false);
    Type orderInfoSDOType = typeHelper.define(orderInfoType);
    DataObject poType = defineType("http://www.globalcompany.com/ns/order", "PurchaseOrderType");
    addProperty(poType, "CustID", stringType, false, false, true);
    addProperty(poType, "ID", stringType, false, false, true);
    addProperty(poType, "ShipTo", usAddressSDOType, true, false, true);
    addProperty(poType, "BillTo", usAddressSDOType, true, false, true);
    addProperty(poType, "UserContact", contactSDOType, true, false, true);
    addProperty(poType, "OrderItems", orderItemsSDOType, true, false, true);
    addProperty(poType, "SupplierInfo", supplierInfoSDOType, true, false, true);
    addProperty(poType, "OrderInfo", orderInfoSDOType, true, false, true);
    Type poSDOType = typeHelper.define(poType);
    DataObject purchaseOrderPropDO = dataFactory.create(propertyType);
    purchaseOrderPropDO.set("name", "PurchaseOrder");
    purchaseOrderPropDO.set("type", poSDOType);
    Property prop = typeHelper.defineOpenContentProperty("http://www.globalcompany.com/ns/order", purchaseOrderPropDO);
    DataObject purchaseOrderPropDO2 = dataFactory.create(propertyType);
    purchaseOrderPropDO2.set("name", "PurchaseOrder2");
    purchaseOrderPropDO2.set("type", poSDOType);
    Property prop2 = typeHelper.defineOpenContentProperty("http://www.globalcompany.com/ns/order", purchaseOrderPropDO2);
    DataObject purchaseOrderPropDO3 = dataFactory.create(propertyType);
    purchaseOrderPropDO3.set("name", "PurchaseOrder3");
    purchaseOrderPropDO3.set("type", poSDOType);
    Property prop3 = typeHelper.defineOpenContentProperty("http://www.globalcompany.com/ns/order", purchaseOrderPropDO3);
    DataObject purchaseOrderPropDO4 = dataFactory.create(propertyType);
    purchaseOrderPropDO4.set("name", "PurchaseOrder4");
    purchaseOrderPropDO4.set("type", poSDOType);
    Property prop4 = typeHelper.defineOpenContentProperty("http://www.globalcompany.com/ns/order", purchaseOrderPropDO4);
    // create a new Type for Customers
    // TODO: the getControlRootURI is not in the NamespaceResolver for the type
    DataObject SOAOrderBookingProcessRequestTypeDO = defineType(getControlRootURI(), "SOAOrderBookingProcessRequest");
    SOAOrderBookingProcessRequestTypeDO.set("open", true);
    // DataObject poProp = addProperty(SOAOrderBookingProcessRequestTypeDO, "PurchaseOrder", poSDOType, true, false, true);
    // now define the Customer type so that customers can be made
    Type SOAOrderBookingProcessRequestType = typeHelper.define(SOAOrderBookingProcessRequestTypeDO);
    DataObject SOAOrderBookingProcessRequestPropDO = dataFactory.create(propertyType);
    SOAOrderBookingProcessRequestPropDO.set("name", getControlRootName());
    SOAOrderBookingProcessRequestPropDO.set("type", SOAOrderBookingProcessRequestType);
    typeHelper.defineOpenContentProperty(getControlRootURI(), SOAOrderBookingProcessRequestPropDO);
}
Also used : Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType) Property(commonj.sdo.Property)

Example 99 with SDOType

use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.

the class ChangeSummaryChildLoadAndSaveTestCases method registerTypes.

@Override
protected void registerTypes() {
    Type stringType = typeHelper.getType("commonj.sdo", "String");
    Type employeeType = registerEmployeeType();
    SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
    // create a new Type for Customers
    DataObject teamType = dataFactory.create("commonj.sdo", "Type");
    SDOProperty prop = (SDOProperty) teamType.getType().getProperty("uri");
    teamType.set(prop, getControlRootURI());
    prop = (SDOProperty) teamType.getType().getProperty("name");
    teamType.set(prop, "team");
    addProperty(teamType, "name", stringType);
    DataObject managerProp = addProperty(teamType, "manager", employeeType);
    managerProp.setBoolean("containment", true);
    Type teamSDOType = typeHelper.define(teamType);
    DataObject propDO = dataFactory.create(propertyType);
    propDO.set("name", getControlRootName());
    propDO.set("type", teamSDOType);
    typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty)

Example 100 with SDOType

use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.

the class LoadAndSaveNillableIsSetNodeNullPolicyTrueTestCases method registerTypes.

@Override
public void registerTypes() {
    SDOType stringType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.STRING);
    SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
    SDOType typeType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.TYPE);
    // ADDRESS TYPE
    DataObject addressTypeDO = dataFactory.create(typeType);
    addressTypeDO.set("uri", getControlRootURI());
    addressTypeDO.set("name", "AddressType");
    DataObject addressCityProperty = addProperty(addressTypeDO, "city", stringType, false, false, true);
    addressCityProperty.set("nullable", true);
    Type addressType = typeHelper.define(addressTypeDO);
    // create a new Type for Customers
    DataObject customerType = dataFactory.create(typeType);
    customerType.set("uri", getControlRootURI());
    customerType.set("name", "EmployeeType");
    // customerType.set("name", "Employee");
    // create an idproperty
    DataObject idProp = addProperty(customerType, "id", stringType, false, false, true);
    idProp.set("nullable", true);
    DataObject fnameProp = addProperty(customerType, "first-name", stringType, false, false, true);
    fnameProp.set("nullable", true);
    addProperty(customerType, "task", stringType, false, true, true);
    addProperty(customerType, "last-name", stringType, false, false, true);
    DataObject addressProp = addProperty(customerType, "address", addressType, true, false, true);
    addressProp.set("nullable", true);
    // now define the Customer type so that customers can be made
    Type customerSDOType = typeHelper.define(customerType);
    DataObject propDO = dataFactory.create(propertyType);
    propDO.set("name", getControlRootName());
    propDO.set("type", customerSDOType);
    typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType)

Aggregations

SDOType (org.eclipse.persistence.sdo.SDOType)318 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)158 DataObject (commonj.sdo.DataObject)139 Type (commonj.sdo.Type)132 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)102 ArrayList (java.util.ArrayList)89 List (java.util.List)83 QName (javax.xml.namespace.QName)31 Property (commonj.sdo.Property)30 SDOTypeHelper (org.eclipse.persistence.sdo.helper.SDOTypeHelper)17 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)13 ChangeSummary (commonj.sdo.ChangeSummary)11 SDOWrapperType (org.eclipse.persistence.sdo.types.SDOWrapperType)10 ComplexType (org.eclipse.persistence.internal.oxm.schema.model.ComplexType)9 SimpleType (org.eclipse.persistence.internal.oxm.schema.model.SimpleType)9 XMLDocument (commonj.sdo.helper.XMLDocument)8 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)8 SDODataType (org.eclipse.persistence.sdo.types.SDODataType)7 IOException (java.io.IOException)6 FileInputStream (java.io.FileInputStream)5