Package commonj.sdo

Examples of commonj.sdo.Type


        try {
            Field field = exceptionType.getField("FAULT_ELEMENT");
            faultElement = (QName)field.get(null);
        } catch (NoSuchFieldException e) {
            // Fall back to type inspection
            Type type = helperContext.getTypeHelper().getType(faultBeanClass);
            if (type != null && !type.isDataType()) {
                String ns = type.getURI();
                String name = helperContext.getXSDHelper().getLocalName(type);
                faultElement = new QName(ns, name);
            }
        } catch (Throwable e) {
            // Ignore
View Full Code Here


                dataType.setLogical(XMLType.UNKNOWN);
            }
            return true;
        }
        // FIXME: We need to access HelperContext
        Type type = context.getTypeHelper().getType(javaType);
        if (type == null) {
            return false;
        }
        if (type.isDataType()) {
            // FIXME: Ignore simple types?
            return false;
        }
        String namespace = type.getURI();
        String name = context.getXSDHelper().getLocalName(type);
        QName xmlType = new QName(namespace, name);
        dataType.setDataBinding(getName());
        QName elementName = null;
        Object logical = dataType.getLogical();
View Full Code Here

                dataType.setLogical(XMLType.UNKNOWN);
            }
            return true;
        }
        // FIXME: We need to access HelperContext
        Type type = context.getTypeHelper().getType(javaType);
        if (type == null) {
            return false;
        }
        if (type.isDataType()) {
            // FIXME: Ignore simple types?
            return false;
        }
        String namespace = type.getURI();
        String name = context.getXSDHelper().getLocalName(type);
        QName xmlType = new QName(namespace, name);
        dataType.setDataBinding(getName());
        QName elementName = null;
        Object logical = dataType.getLogical();
View Full Code Here

     * @param javaType
     */

    private static boolean register(HelperContext helperContext, Class javaType) {
        try {
            Type type = helperContext.getTypeHelper().getType(javaType);
            if (type != null && (!type.isDataType())) {
                Method method = type.getClass().getMethod("getEPackage", new Class[] {});
                Object factory = method.invoke(type, new Object[] {});
                method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
                method.invoke(factory, new Object[] {helperContext});
                return true;
            }
View Full Code Here

    }

    lineBreak();
    indent();
    buf.append("DataObject: ");
    Type type = dataObject.getType();
    buf.append("Type: ").append(type.getURI()).append('#').append(
        type.getName());
    lineBreak();

    if (dataObject.getType().isSequenced()) {

      commentary(
View Full Code Here

    List typeDeclarations = new ArrayList();

    TypeHelper typeHelper = scope.getTypeHelper();

    Type stringType = typeHelper.getType(sdoApiUri, "String");
    Type dateType = typeHelper.getType(sdoApiUri, "Date");
    Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");

    // <complexType name="Person">
    // <sequence>
    // <element name="dob" type="date"/>
    // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
View Full Code Here

    public UpdateCommandImpl getUpdateCommand(MappingWrapper mapping, DataObject changedObject, Table table) {
        List updatedProperties = new ArrayList();
        List managedProperties = new ArrayList();
        List whereClauseProperties = new ArrayList();
        Type type = changedObject.getType();
        TableWrapper t = new TableWrapper(table);
        StringBuffer statement = new StringBuffer("update ");
        statement.append(table.getTableName());
        statement.append(" set ");

        ChangeSummary summary = changedObject.getDataGraph().getChangeSummary();
        Iterator i = getChangedFields(mapping, summary, changedObject).iterator();

        while (i.hasNext()) {
            Property property = (Property) i.next();
            Column c = t.getColumnByPropertyName(property.getName());
            if ((c != null) && (c.isCollision() || c.isPrimaryKey())) {
                // get rid of comma if OCC or PK is last field
                if (!i.hasNext()) {
                    statement.delete(statement.length() - 2, statement.length());
                }
            } else {
                updatedProperties.add(property);
                statement.append(c == null ? property.getName() : c.getColumnName());
                statement.append(" = ?");
                if (i.hasNext()) {
                    statement.append(", ");
                }
            }
        }

        Column c = t.getManagedColumn();
        if (c != null) {
            statement.append(", ");
            statement.append(c.getColumnName());
            statement.append(" = ?");
            managedProperties.add(changedObject.getProperty(t.getManagedColumnPropertyName()));
        }
        statement.append(" where ");

        Iterator names = t.getPrimaryKeyNames().iterator();
        Iterator pkProperties = t.getPrimaryKeyProperties().iterator();
        while (names.hasNext() && pkProperties.hasNext()) {
            String name = (String) names.next();
            String property = (String) pkProperties.next();
            statement.append(name);
            statement.append(" = ?");
            if (names.hasNext() && pkProperties.hasNext()) {
                statement.append(" and ");
            }
            whereClauseProperties.add(type.getProperty(property));
        }

        if (t.getCollisionColumn() != null) {
            statement.append(" and ");
            statement.append(t.getCollisionColumn().getColumnName());
            statement.append(" = ?");
            whereClauseProperties.add(type.getProperty(t.getCollisionColumnPropertyName()));
        }

        UpdateCommandImpl updateCommand;
        if (t.getCollisionColumn() != null) {
            updateCommand = new OptimisticWriteCommandImpl(statement.toString());
View Full Code Here

            int index = p.getColumnType().lastIndexOf('.');
            String pkg = p.getColumnType().substring(0, index);
            String typeName = p.getColumnType().substring(index + 1);

            Type sdoType = TypeHelper.INSTANCE.getType(pkg, typeName);

            int direction = ParameterImpl.IN;
            if ("OUT".equalsIgnoreCase(p.getDirection())) {
                direction = ParameterImpl.OUT;
            } else if ("INOUT".equalsIgnoreCase(p.getDirection())) {
View Full Code Here

            throw new RuntimeException("DataObjectModel must be specified in the Config");
        }

        String uri = "http:///org.apache.tuscany.das.rdb/das";
        TypeHelper typeHelper = SDOUtil.createTypeHelper();
        Type rootType = SDOUtil.createType(typeHelper, uri + "/DataGraphRoot", "DataGraphRoot", false);

        List types = SDOUtil.getTypes(typeHelper, config.getDataObjectModel());
        if (types == null) {
            throw new RuntimeException("SDO Types have not been registered for URI " + config.getDataObjectModel());
        }

        Iterator i = types.iterator();
        while (i.hasNext()) {
            Type type = (Type) i.next();
            Property property = SDOUtil.createProperty(rootType, type.getName(), type);
            SDOUtil.setContainment(property, true);
            SDOUtil.setMany(property, true);
        }

        // Create the DataGraph
View Full Code Here

    private void createDynamicTypes() {

        DataObjectUtil.initRuntime();

        Type root = SDOUtil.createType(typeHelper, getDefaultURI(), "DataGraphRoot", false);

        Iterator iter = getResultMetadata().iterator();
        while (iter.hasNext()) {

            ResultMetadata resultMetadata = (ResultMetadata) iter.next();

            // Create a Type for each Table represented in the ResultSet
            Iterator names = resultMetadata.getAllTablePropertyNames().iterator();
            while (names.hasNext()) {
                String tableName = (String) names.next();

                if (root.getProperty(tableName) == null) {
                    Type tableType = SDOUtil.createType(typeHelper, getDefaultURI(), tableName, false);
                    Property property = SDOUtil.createProperty(root, tableName, tableType);
                    SDOUtil.setMany(property, true);
                    SDOUtil.setContainment(property, true);
                }
            }

            // TODO tablePropertyMap is temporary until Tuscany-203 is fixed
            Map tablePropertyMap = new HashMap();

            for (int i = 1; i <= resultMetadata.getResultSetSize(); i++) {

                Property ref = root.getProperty(resultMetadata.getTablePropertyName(i));

                if (ref == null) {
                    throw new RuntimeException("Could not find table " + resultMetadata.getTablePropertyName(i)
                            + " in the SDO model");
                }
               
                // TODO Temporary code to check to see if a property has already been added.
                // Replace when Tuscany-203 is fixed
                List addedProperties = (List) tablePropertyMap.get(ref.getName());
                if (addedProperties == null) {
                    addedProperties = new ArrayList();
                    tablePropertyMap.put(ref.getName(), addedProperties);
                }


                String columnName = resultMetadata.getColumnPropertyName(i);

                // TODO temporary check until Tuscany-203 is fixed
                if (!addedProperties.contains(columnName)) {
                    addedProperties.add(columnName);
                    Type atype = resultMetadata.getDataType(i);

                    SDOUtil.createProperty(ref.getType(), columnName, atype);

                }

            }
        }

        MappingWrapper wrapper = getConfigWrapper();
        Iterator i = getRelationships().iterator();
        while (i.hasNext()) {
            Relationship r = (Relationship) i.next();

            String parentName = wrapper.getTableTypeName(r.getPrimaryKeyTable());
            String childName = wrapper.getTableTypeName(r.getForeignKeyTable());

            if (parentName == null) {
                throw new RuntimeException("The parent table (" + r.getPrimaryKeyTable()
                        + ") in relationship " + r.getName()
                        + " was not found in the mapping information.");
            } else if (childName == null) {
                throw new RuntimeException("The child table (" + r.getForeignKeyTable()
                        + ") in relationship " + r.getName()
                        + " was not found in the mapping information.");
            }

            Property parentProperty = root.getProperty(parentName);
            Property childProperty = root.getProperty(childName);

            if (parentProperty == null) {
                throw new RuntimeException("The parent table (" + parentName + ") in relationship "
                        + r.getName() + " was not found.");
            } else if (childProperty == null) {
                throw new RuntimeException("The child table (" + childName + ") in relationship "
                        + r.getName() + " was not found.");
            }

            Type parent = parentProperty.getType();
            Type child = childProperty.getType();

            Property parentProp = SDOUtil.createProperty(parent, r.getName(), child);
            Property childProp = SDOUtil.createProperty(child, r.getName() + "_opposite", parent);
            SDOUtil.setOpposite(parentProp, childProp);
            SDOUtil.setOpposite(childProp, parentProp);
View Full Code Here

TOP

Related Classes of commonj.sdo.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.