/** * INTERNAL: Make this Type an opened Type to allow open content by assigning true value or a Type * not to accept any additional properties by assigning false value, {@link isOpen()}. * * @param bOpen boolean value implying if this Type is open */ public void setOpen(boolean bOpen) { if (isDataType() && bOpen) { throw SDOException.typeCannotBeOpenAndDataType(getURI(), getName()); } if (open != bOpen) { open = bOpen; if (open) { if (isSubType()) { Type baseType = (Type) getBaseTypes().get(0); if (!baseType.isOpen()) { addOpenMappings(); } } else { addOpenMappings(); } if (isBaseType()) { for (int i = 0; i < getSubTypes().size(); i++) { SDOType nextSubType = (SDOType) getSubTypes().get(i); nextSubType.setOpen(bOpen); } } } } }
public boolean isInstance(Object object) { if ((!isDataType()) && (object instanceof DataObject)) { Type doType = ((DataObject) object).getType(); if (doType != null) { return doType.equals(this); } } // this check is taken from page 77 of the spec Class instanceClass = getInstanceClass(); if (instanceClass != null) { return instanceClass.isInstance(object); } return false; }
private void updateSubtypes(Type baseType) { getProperties().addAll(0, baseType.getProperties()); if (isBaseType()) { for (int i = 0; i < getSubTypes().size(); i++) { SDOType nextSubType = (SDOType) getSubTypes().get(i); nextSubType.updateSubtypes(baseType); } } }
public List<Type> getControlTypes() { List<Type> types = new ArrayList<Type>(); ((SDOTypeHelper) typeHelper).reset(); DataObject phoneTypeDO = dataFactory.create("commonj.sdo", "Type"); phoneTypeDO.set("uri", "my.uri"); phoneTypeDO.set("name", "phoneType"); phoneTypeDO.set("sequenced", true); DataObject areaCodeProp = addProperty(phoneTypeDO, "areaCode", SDOConstants.SDO_STRING); DataObject numberProp = addProperty(phoneTypeDO, "number", SDOConstants.SDO_OBJECT); numberProp.set("many", true); Type phoneType = typeHelper.define(phoneTypeDO); ((SDOProperty) phoneType.getProperty("areaCode")).setXsd(true); ((SDOProperty) phoneType.getProperty("areaCode")).setContainment(true); ((SDOProperty) phoneType.getProperty("areaCode")).setXsdLocalName("areaCode"); ((SDOProperty) phoneType.getProperty("number")).setXsd(true); ((SDOProperty) phoneType.getProperty("number")).setContainment(true); ((SDOProperty) phoneType.getProperty("number")).setXsdLocalName("number"); DataObject personTypeDO = dataFactory.create("commonj.sdo", "Type"); personTypeDO.set("uri", "my.uri"); personTypeDO.set("name", "personType"); personTypeDO.set("sequenced", true); addProperty(personTypeDO, "age", SDOConstants.SDO_STRING); DataObject nameProp = addProperty(personTypeDO, "name", SDOConstants.SDO_OBJECT); nameProp.set("many", true); Type personType = typeHelper.define(personTypeDO); ((SDOProperty) personType.getProperty("age")).setXsd(true); ((SDOProperty) personType.getProperty("age")).setContainment(true); ((SDOProperty) personType.getProperty("age")).setXsdLocalName("age"); ((SDOProperty) personType.getProperty("name")).setXsd(true); ((SDOProperty) personType.getProperty("name")).setContainment(true); ((SDOProperty) personType.getProperty("name")).setXsdLocalName("name"); DataObject jobTypeDO = dataFactory.create("commonj.sdo", "Type"); jobTypeDO.set("uri", "my.uri"); jobTypeDO.set("name", "jobType"); jobTypeDO.set("sequenced", true); DataObject titleProp = addProperty(jobTypeDO, "title", SDOConstants.SDO_OBJECT); titleProp.set("many", true); Type jobType = typeHelper.define(jobTypeDO); ((SDOProperty) jobType.getProperty("title")).setXsd(true); ((SDOProperty) jobType.getProperty("title")).setContainment(true); ((SDOProperty) jobType.getProperty("title")).setXsdLocalName("title"); DataObject contactTypeDO = dataFactory.create("commonj.sdo", "Type"); contactTypeDO.set("uri", "my.uri"); contactTypeDO.set("name", "contactType"); contactTypeDO.set("sequenced", true); DataObject streetProp = addProperty(contactTypeDO, "street", SDOConstants.SDO_OBJECT); streetProp.set("many", true); Type contactType = typeHelper.define(contactTypeDO); ((SDOProperty) contactType.getProperty("street")).setXsd(true); ((SDOProperty) contactType.getProperty("street")).setContainment(true); ((SDOProperty) contactType.getProperty("street")).setXsdLocalName("street"); DataObject addressTypeDO = dataFactory.create("commonj.sdo", "Type"); addressTypeDO.set("uri", "my.uri"); addressTypeDO.set("name", "addressType"); addressTypeDO.set("sequenced", true); List baseTypes = new ArrayList(); baseTypes.add(contactType); addressTypeDO.set("baseType", baseTypes); DataObject cityProp = addProperty(addressTypeDO, "city", SDOConstants.SDO_STRING); Type addressType = typeHelper.define(addressTypeDO); ((SDOProperty) addressType.getProperty("city")).setXsd(true); ((SDOProperty) addressType.getProperty("city")).setContainment(true); ((SDOProperty) addressType.getProperty("city")).setXsdLocalName("city"); DataObject cdnAddressTypeDO = dataFactory.create("commonj.sdo", "Type"); cdnAddressTypeDO.set("uri", "my.uri"); cdnAddressTypeDO.set("name", "cdnAddressType"); cdnAddressTypeDO.set("sequenced", true); baseTypes = new ArrayList(); baseTypes.add(addressType); cdnAddressTypeDO.set("baseType", baseTypes); DataObject postalCodeProp = addProperty(cdnAddressTypeDO, "postalCode", SDOConstants.SDO_STRING); Type cdnAddressType = typeHelper.define(cdnAddressTypeDO); ((SDOProperty) cdnAddressType.getProperty("postalCode")).setXsd(true); ((SDOProperty) cdnAddressType.getProperty("postalCode")).setContainment(true); ((SDOProperty) cdnAddressType.getProperty("postalCode")).setXsdLocalName("postalCode"); types.add(personType); types.add(jobType); types.add(addressType); types.add(contactType); types.add(cdnAddressType); types.add(phoneType); return types; }
/** * Returns true if the Type is declared to contain mixed content. A DataObject's mixed content * values are typically accessed via a Sequence. * * @param type to identify if mixed content. * @return true if the Type is declared to contain mixed content. */ public boolean isMixed(Type type) { if (type == null) { return false; } return type.isSequenced(); }
/** * Returns the namespace URI as declared in the XSD. * * @param type to return namespace URI for. * @return the namespace URI as declared in the XSD. */ public String getNamespaceURI(Type type) { if (type == null) { return null; } return type.getURI(); }
public List getControlTypes() { SDOType changeSummaryType = (SDOType) aHelperContext .getTypeHelper() .getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY); List<Type> types = new ArrayList<Type>(); ((SDOTypeHelper) typeHelper).reset(); // String xsdSchema = // getSchema("org/eclipse/persistence/testing/sdo/schemas/PurchaseOrderComplexSequenced.xsd"); // List types = xsdHelper.define(xsdSchema); DataObject addressTypeDO = dataFactory.create("commonj.sdo", "Type"); addressTypeDO.set("uri", NON_DEFAULT_URI); addressTypeDO.set("name", "AddressType"); addressTypeDO.set("sequenced", true); addProperty(addressTypeDO, "name", SDOConstants.SDO_STRING, false, false, true); addProperty(addressTypeDO, "street", SDOConstants.SDO_STRING, false, true, true); addProperty(addressTypeDO, "city", SDOConstants.SDO_STRING, false, false, true); Type addressType = typeHelper.define(addressTypeDO); ((SDOProperty) addressType.getProperty("name")).setXsd(true); ((SDOProperty) addressType.getProperty("name")).setXsdLocalName("name"); ((SDOProperty) addressType.getProperty("street")).setXsd(true); ((SDOProperty) addressType.getProperty("street")).setXsdLocalName("street"); ((SDOProperty) addressType.getProperty("city")).setXsd(true); ((SDOProperty) addressType.getProperty("city")).setXsdLocalName("city"); // ----------------- DataObject usAddressTypeDO = dataFactory.create("commonj.sdo", "Type"); usAddressTypeDO.set("uri", NON_DEFAULT_URI); usAddressTypeDO.set("name", "usAddressType"); usAddressTypeDO.set("sequenced", true); List<Type> baseTypes = new ArrayList<Type>(); baseTypes.add(addressType); usAddressTypeDO.set("baseType", baseTypes); DataObject stateProp = addProperty(usAddressTypeDO, "state", SDOConstants.SDO_STRING); stateProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); Type usAddressType = typeHelper.define(usAddressTypeDO); ((SDOProperty) usAddressType.getProperty("state")).setXsd(true); ((SDOProperty) usAddressType.getProperty("state")).setXsdLocalName("state"); // ----------------- DataObject cdnAddressTypeDO = dataFactory.create("commonj.sdo", "Type"); cdnAddressTypeDO.set("uri", NON_DEFAULT_URI); cdnAddressTypeDO.set("name", "cdnAddressType"); cdnAddressTypeDO.set("sequenced", true); baseTypes = new ArrayList<Type>(); // reset baseTypes.add(addressType); cdnAddressTypeDO.set("baseType", baseTypes); addProperty(cdnAddressTypeDO, "province", SDOConstants.SDO_STRING, false, false, true); addProperty(cdnAddressTypeDO, "postalcode", SDOConstants.SDO_STRING, false, false, true); Type cdnAddressType = typeHelper.define(cdnAddressTypeDO); ((SDOProperty) cdnAddressType.getProperty("province")).setXsd(true); ((SDOProperty) cdnAddressType.getProperty("province")).setXsdLocalName("province"); ((SDOProperty) cdnAddressType.getProperty("postalcode")).setXsd(true); ((SDOProperty) cdnAddressType.getProperty("postalcode")).setXsdLocalName("postalcode"); // ----------------- DataObject cdnAddressMailingTypeDO = dataFactory.create("commonj.sdo", "Type"); cdnAddressMailingTypeDO.set("uri", NON_DEFAULT_URI); cdnAddressMailingTypeDO.set("name", "cdnAddressMailingType"); cdnAddressMailingTypeDO.set("sequenced", true); baseTypes = new ArrayList<Type>(); // reset baseTypes.add(cdnAddressType); cdnAddressMailingTypeDO.set("baseType", baseTypes); DataObject deliveryInfoProp = addProperty(cdnAddressMailingTypeDO, "deliveryInfo", SDOConstants.SDO_STRING); deliveryInfoProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); Type cdnAddressMailingType = typeHelper.define(cdnAddressMailingTypeDO); ((SDOProperty) cdnAddressMailingType.getProperty("deliveryInfo")).setXsd(true); ((SDOProperty) cdnAddressMailingType.getProperty("deliveryInfo")) .setXsdLocalName("deliveryInfo"); // ----------------- DataObject itemTypeDO = dataFactory.create("commonj.sdo", "Type"); itemTypeDO.set("uri", NON_DEFAULT_URI); itemTypeDO.set("name", "LineItemType"); DataObject prodcutNameProp = addProperty(itemTypeDO, "productName", SDOConstants.SDO_STRING); prodcutNameProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); DataObject priceProp = addProperty(itemTypeDO, "price", SDOConstants.SDO_FLOAT); priceProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); DataObject shipDateProp = addProperty(itemTypeDO, "shipDate", SDOConstants.SDO_STRING); shipDateProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); DataObject commentProp = addProperty(itemTypeDO, "comment", SDOConstants.SDO_STRING); commentProp.set(SDOConstants.XMLELEMENT_PROPERTY, true); Type itemType = typeHelper.define(itemTypeDO); ((SDOProperty) itemType.getProperty("productName")).setXsd(true); ((SDOProperty) itemType.getProperty("productName")).setXsdLocalName("productName"); ((SDOProperty) itemType.getProperty("price")).setXsd(true); ((SDOProperty) itemType.getProperty("price")).setXsdLocalName("price"); ((SDOProperty) itemType.getProperty("shipDate")).setXsd(true); ((SDOProperty) itemType.getProperty("shipDate")).setXsdLocalName("shipDate"); ((SDOProperty) itemType.getProperty("comment")).setXsd(true); ((SDOProperty) itemType.getProperty("comment")).setXsdLocalName("comment"); // ----------------- DataObject itemsTypeDO = dataFactory.create("commonj.sdo", "Type"); itemsTypeDO.set("uri", NON_DEFAULT_URI); itemsTypeDO.set("name", "Items"); itemsTypeDO.set("sequenced", true); addProperty(itemsTypeDO, "item", itemType, true, true, true); Type itemsType = typeHelper.define(itemsTypeDO); ((SDOProperty) itemsType.getProperty("item")).setXsd(true); ((SDOProperty) itemsType.getProperty("item")).setXsdLocalName("item"); // ----------------- DataObject poTypeDO = dataFactory.create("commonj.sdo", "Type"); poTypeDO.set("uri", NON_DEFAULT_URI); poTypeDO.set("name", "PurchaseOrderType"); addProperty(poTypeDO, "address", addressType, true, true, true); addProperty(poTypeDO, "comment", SDOConstants.SDO_STRING, false, false, true); addProperty(poTypeDO, "items", itemsType, true, false, true); Type poType = typeHelper.define(poTypeDO); ((SDOProperty) poType.getProperty("address")).setXsd(true); ((SDOProperty) poType.getProperty("address")).setXsdLocalName("address"); ((SDOProperty) poType.getProperty("comment")).setXsd(true); ((SDOProperty) poType.getProperty("comment")).setXsdLocalName("comment"); ((SDOProperty) poType.getProperty("items")).setXsd(true); ((SDOProperty) poType.getProperty("items")).setXsdLocalName("items"); // ((SDOProperty)poType.getProperty("myCS")).setXsd(true); // ((SDOProperty)poType.getProperty("myCS")).setXsdLocalName("myCS"); // ----------------- DataObject companyTypeDO = dataFactory.create("commonj.sdo", "Type"); companyTypeDO.set("uri", NON_DEFAULT_URI); companyTypeDO.set("name", "CompanyType"); DataObject csProp = addProperty(companyTypeDO, "myCS", changeSummaryType, true, false, true); csProp.set("readOnly", true); addProperty(companyTypeDO, "order", poType, true, false, true); Type companyType = typeHelper.define(companyTypeDO); ((SDOProperty) companyType.getProperty("myCS")).setXsd(true); ((SDOProperty) companyType.getProperty("myCS")).setXsdLocalName("myCS"); ((SDOProperty) companyType.getProperty("order")).setXsd(true); ((SDOProperty) companyType.getProperty("order")).setXsdLocalName("order"); // ------------------ types.add(companyType); types.add(cdnAddressType); types.add(usAddressType); types.add(itemsType); types.add(poType); types.add(cdnAddressMailingType); types.add(itemType); types.add(addressType); return types; }