Search in sources :

Example 1 with DBWSModel

use of org.eclipse.persistence.dbws.DBWSModel in project eclipselink by eclipse-ee4j.

the class DBWSTestSuite method setUp.

/**
 * This method should be used when sessions xml is to be generated and written out
 * to DBWS_SESSION_STREAM.
 *
 * @param stageDir sessions xml will be generated and written out if non-null
 */
public static void setUp(String stageDir, boolean useLogger) throws WSDLException {
    comparer.setIgnoreOrder(true);
    if (builder == null) {
        builder = new DBWSBuilder();
    }
    DBWS_SERVICE_STREAM = new ByteArrayOutputStream();
    DBWS_SCHEMA_STREAM = new ByteArrayOutputStream();
    DBWS_SESSION_STREAM = new ByteArrayOutputStream();
    DBWS_OR_STREAM = new ByteArrayOutputStream();
    DBWS_OX_STREAM = new ByteArrayOutputStream();
    DBWS_WSDL_STREAM = new ByteArrayOutputStream();
    final String username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    final String password = System.getProperty(DATABASE_PASSWORD_KEY, DEFAULT_DATABASE_PASSWORD);
    final String url = System.getProperty(DATABASE_URL_KEY, DEFAULT_DATABASE_URL);
    String builderString = DBWS_BUILDER_XML_USERNAME + username + DBWS_BUILDER_XML_PASSWORD + password + DBWS_BUILDER_XML_URL + url + DBWS_BUILDER_XML_DRIVER + DATABASE_DRIVER + DBWS_BUILDER_XML_PLATFORM + DATABASE_PLATFORM + DBWS_BUILDER_XML_MAIN;
    XMLContext context = new XMLContext(new DBWSBuilderModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSBuilderModel builderModel = (DBWSBuilderModel) unmarshaller.unmarshal(new StringReader(builderString));
    builder.quiet = true;
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.properties = builderModel.properties;
    builder.operations = builderModel.operations;
    XRPackager xrPackager = new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        // do nothing - don't have to verify existence of 'stageDir' when
        // all the streams are in-memory
        }
    };
    xrPackager.setDBWSBuilder(builder);
    builder.setPackager(xrPackager);
    builder.setPackager(xrPackager);
    dbwsLogger = null;
    if (useLogger) {
        dbwsLogger = new DBWSLogger("DBWSTestLogger", null);
    }
    if (stageDir == null) {
        builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
        builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, dbwsLogger);
    } else {
        xrPackager.setStageDir(new File(stageDir));
        builder.build(DBWS_SCHEMA_STREAM, DBWS_SESSION_STREAM, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, dbwsLogger);
    }
    XRServiceFactory factory = new XRServiceFactory() {

        @Override
        public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
            parentClassLoader = this.getClass().getClassLoader();
            xrSchemaStream = new ByteArrayInputStream(DBWS_SCHEMA_STREAM.toByteArray());
            return super.buildService(xrServiceModel);
        }

        @Override
        public void buildSessions() {
            XRDynamicClassLoader xrdecl = new XRDynamicClassLoader(parentClassLoader);
            DatasourceLogin login = new DatabaseLogin();
            login.setUserName(username);
            login.setPassword(password);
            ((DatabaseLogin) login).setConnectionString(url);
            ((DatabaseLogin) login).setDriverClassName(DATABASE_PLATFORM);
            Platform platform = builder.getDatabasePlatform();
            ConversionManager conversionManager = platform.getConversionManager();
            if (conversionManager != null) {
                conversionManager.setLoader(xrdecl);
            }
            login.setDatasourcePlatform(platform);
            ((DatabaseLogin) login).bindAllParameters();
            Project orProject = null;
            if (DBWS_OR_STREAM.size() != 0) {
                MetadataProcessor processor = new MetadataProcessor(new XRPersistenceUnitInfo(xrdecl), new DatabaseSessionImpl(login), xrdecl, false, true, false, false, false, null, null);
                processor.setMetadataSource(new JPAMetadataSource(xrdecl, new StringReader(DBWS_OR_STREAM.toString())));
                PersistenceUnitProcessor.processORMetadata(processor, true, PersistenceUnitProcessor.Mode.ALL);
                processor.addNamedQueries();
                orProject = processor.getProject().getProject();
            } else {
                orProject = new Project();
            }
            orProject.setName(builder.getProjectName().concat(OR_PRJ_SUFFIX));
            orProject.setDatasourceLogin(login);
            DatabaseSession databaseSession = orProject.createDatabaseSession();
            if ("off".equalsIgnoreCase(builder.getLogLevel())) {
                databaseSession.dontLogMessages();
            } else {
                databaseSession.setLogLevel(AbstractSessionLog.translateStringToLoggingLevel(builder.getLogLevel()));
            }
            xrService.setORSession(databaseSession);
            orProject.convertClassNamesToClasses(xrdecl);
            Project oxProject = null;
            if (DBWS_OX_STREAM.size() != 0) {
                Map<String, OXMMetadataSource> metadataMap = new HashMap<String, OXMMetadataSource>();
                StreamSource xml = new StreamSource(new StringReader(DBWS_OX_STREAM.toString()));
                try {
                    JAXBContext jc = JAXBContext.newInstance(XmlBindingsModel.class);
                    Unmarshaller unmarshaller = jc.createUnmarshaller();
                    JAXBElement<XmlBindingsModel> jaxbElt = unmarshaller.unmarshal(xml, XmlBindingsModel.class);
                    XmlBindingsModel model = jaxbElt.getValue();
                    for (XmlBindings xmlBindings : model.getBindingsList()) {
                        metadataMap.put(xmlBindings.getPackageName(), new OXMMetadataSource(xmlBindings));
                    }
                } catch (JAXBException jaxbex) {
                    jaxbex.printStackTrace();
                }
                Map<String, Map<String, OXMMetadataSource>> properties = new HashMap<String, Map<String, OXMMetadataSource>>();
                properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, metadataMap);
                try {
                    org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext jCtx = org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory.createContextFromOXM(xrdecl, properties);
                    oxProject = jCtx.getXMLContext().getSession(0).getProject();
                } catch (JAXBException e) {
                    e.printStackTrace();
                }
            } else {
                oxProject = new Project();
            }
            oxProject.setName(builder.getProjectName().concat(OX_PRJ_SUFFIX));
            login = (DatasourceLogin) oxProject.getDatasourceLogin();
            if (login != null) {
                platform = login.getDatasourcePlatform();
                if (platform != null) {
                    conversionManager = platform.getConversionManager();
                    if (conversionManager != null) {
                        conversionManager.setLoader(xrdecl);
                    }
                }
            }
            prepareDescriptors(oxProject, orProject, xrdecl);
            ProjectHelper.fixOROXAccessors(orProject, oxProject);
            xrService.setORSession(orProject.createDatabaseSession());
            xrService.getORSession().dontLogMessages();
            xrService.setXMLContext(new XMLContext(oxProject));
            xrService.setOXSession(xrService.getXMLContext().getSession(0));
        }
    };
    context = new XMLContext(new DBWSModelProject());
    unmarshaller = context.createUnmarshaller();
    DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(DBWS_SERVICE_STREAM.toString()));
    xrService = factory.buildService(model);
}
Also used : XRPackager(org.eclipse.persistence.tools.dbws.XRPackager) XmlBindings(org.eclipse.persistence.jaxb.xmlmodel.XmlBindings) Platform(org.eclipse.persistence.internal.databaseaccess.Platform) XMLPlatform(org.eclipse.persistence.platform.xml.XMLPlatform) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) HashMap(java.util.HashMap) XRDynamicClassLoader(org.eclipse.persistence.internal.xr.XRDynamicClassLoader) JAXBContext(jakarta.xml.bind.JAXBContext) DBWSBuilder(org.eclipse.persistence.tools.dbws.DBWSBuilder) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) StringReader(java.io.StringReader) ConversionManager(org.eclipse.persistence.internal.helper.ConversionManager) XmlBindingsModel(org.eclipse.persistence.internal.xr.XmlBindingsModel) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) Unmarshaller(jakarta.xml.bind.Unmarshaller) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) DatasourceLogin(org.eclipse.persistence.sessions.DatasourceLogin) DBWSModel(org.eclipse.persistence.dbws.DBWSModel) XMLContext(org.eclipse.persistence.oxm.XMLContext) StreamSource(javax.xml.transform.stream.StreamSource) JAXBException(jakarta.xml.bind.JAXBException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) DBWSBuilderModelProject(org.eclipse.persistence.tools.dbws.DBWSBuilderModelProject) Project(org.eclipse.persistence.sessions.Project) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) XRServiceFactory(org.eclipse.persistence.internal.xr.XRServiceFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) DBWSBuilderModel(org.eclipse.persistence.tools.dbws.DBWSBuilderModel) XRServiceModel(org.eclipse.persistence.internal.xr.XRServiceModel) DBWSBuilderModelProject(org.eclipse.persistence.tools.dbws.DBWSBuilderModelProject) File(java.io.File) MetadataProcessor(org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with DBWSModel

use of org.eclipse.persistence.dbws.DBWSModel in project eclipselink by eclipse-ee4j.

the class VeearrayTestSuite method setUp.

@BeforeClass
public static void setUp() {
    final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    String username = System.getProperty(DATABASE_USERNAME_KEY);
    if (username == null) {
        fail("error retrieving database username");
    }
    String password = System.getProperty(DATABASE_PASSWORD_KEY);
    if (password == null) {
        fail("error retrieving database password");
    }
    String url = System.getProperty(DATABASE_URL_KEY);
    if (url == null) {
        fail("error retrieving database url");
    }
    String driver = System.getProperty(DATABASE_DRIVER_KEY);
    if (driver == null) {
        fail("error retrieving database driver");
    }
    Project orProject = new Project();
    orProject.setName("or-veearray");
    DatabaseLogin login = new DatabaseLogin();
    login.setUserName(username);
    login.setPassword(password);
    login.setConnectionString(url);
    login.setDriverClassName(driver);
    login.setDatasourcePlatform(new Oracle10Platform());
    login.bindAllParameters();
    orProject.setDatasourceLogin(login);
    ObjectRelationalDataTypeDescriptor phoneORDescriptor = new ObjectRelationalDataTypeDescriptor();
    phoneORDescriptor.setAlias("phone");
    phoneORDescriptor.useSoftCacheWeakIdentityMap();
    phoneORDescriptor.setJavaClass(Phone.class);
    phoneORDescriptor.descriptorIsAggregate();
    phoneORDescriptor.setStructureName("XR_VEE_ARRAY_PHONE");
    phoneORDescriptor.addFieldOrdering("AREACODE");
    phoneORDescriptor.addFieldOrdering("PHONENUMBER");
    phoneORDescriptor.addFieldOrdering("PHONETYPE");
    phoneORDescriptor.addDirectMapping("areaCode", "AREACODE");
    phoneORDescriptor.addDirectMapping("phonenumber", "PHONENUMBER");
    phoneORDescriptor.addDirectMapping("type", "PHONETYPE");
    orProject.addDescriptor(phoneORDescriptor);
    ObjectRelationalDataTypeDescriptor employeeORDescriptor = new ObjectRelationalDataTypeDescriptor();
    employeeORDescriptor.useSoftCacheWeakIdentityMap();
    employeeORDescriptor.getQueryManager().checkCacheForDoesExist();
    employeeORDescriptor.setAlias("employee");
    employeeORDescriptor.setJavaClass(Employee.class);
    employeeORDescriptor.addTableName("XR_VEE_ARRAY_EMP");
    employeeORDescriptor.addPrimaryKeyFieldName("XR_VEE_ARRAY_EMP.EMPNO");
    orProject.addDescriptor(employeeORDescriptor);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("XR_VEE_ARRAY_EMP.EMPNO");
    employeeORDescriptor.addMapping(idMapping);
    DirectToFieldMapping firstNameMapping = new DirectToFieldMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setFieldName("XR_VEE_ARRAY_EMP.FNAME");
    employeeORDescriptor.addMapping(firstNameMapping);
    DirectToFieldMapping lastNameMapping = new DirectToFieldMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setFieldName("XR_VEE_ARRAY_EMP.LNAME");
    employeeORDescriptor.addMapping(lastNameMapping);
    ObjectArrayMapping phonesMapping = new ObjectArrayMapping();
    phonesMapping.setAttributeName("phones");
    phonesMapping.setStructureName("XR_VEE_ARRAY_PHONES");
    phonesMapping.setReferenceClass(Phone.class);
    phonesMapping.setFieldName("PHONES");
    employeeORDescriptor.addMapping(phonesMapping);
    ReadAllQuery raq = new ReadAllQuery(Employee.class);
    raq.setName("getVeeArrayEmployees");
    raq.refreshIdentityMapResult();
    StoredProcedureCall spCall = new StoredProcedureCall();
    spCall.setProcedureName("GET_VEE_ARRAY_EMPS");
    spCall.useNamedCursorOutputAsResultSet("X");
    raq.setCall(spCall);
    employeeORDescriptor.getQueryManager().addQuery("getVeeArrayEmployees", raq);
    ReadObjectQuery roq = new ReadObjectQuery(Employee.class);
    roq.setName("getVeeArrayEmployee");
    roq.refreshIdentityMapResult();
    roq.addArgument("X");
    spCall = new StoredProcedureCall();
    spCall.setProcedureName("GET_VEE_ARRAY_EMP");
    spCall.addNamedArgument("X", "X", Types.INTEGER);
    spCall.useNamedCursorOutputAsResultSet("Y");
    roq.setCall(spCall);
    employeeORDescriptor.getQueryManager().addQuery("getVeeArrayEmployee", roq);
    ObjectRelationalDatabaseField ordf = new ObjectRelationalDatabaseField("");
    ordf.setSqlType(Types.STRUCT);
    ordf.setSqlTypeName("XR_VEE_ARRAY_PHONE");
    ordf.setType(Phone.class);
    DataModifyQuery dataModifyQuery = new DataModifyQuery();
    dataModifyQuery.setName("updateVeeArrayPhones");
    dataModifyQuery.addArgument("X");
    dataModifyQuery.addArgument("Y");
    spCall = new StoredProcedureCall();
    spCall.setProcedureName("UPDATE_VEE_ARRAY_PHS");
    spCall.addNamedArgument("X", "X", Types.INTEGER);
    spCall.addNamedArgument("Y", "Y", Types.ARRAY, "XR_VEE_ARRAY_PHONES", ordf);
    dataModifyQuery.setCall(spCall);
    employeeORDescriptor.getQueryManager().addQuery("updateVeeArrayPhones", dataModifyQuery);
    NamespaceResolver ns = new NamespaceResolver();
    ns.setDefaultNamespaceURI("urn:veearray");
    Project oxProject = new Project();
    oxProject.setName("ox-veearray");
    XMLLogin xmlLogin = new XMLLogin();
    xmlLogin.getProperties().remove("user");
    xmlLogin.getProperties().remove("password");
    oxProject.setLogin(xmlLogin);
    XMLDescriptor employeeOXDescriptor = new XMLDescriptor();
    employeeOXDescriptor.setAlias("employee");
    employeeOXDescriptor.setJavaClass(Employee.class);
    employeeOXDescriptor.setDefaultRootElement("employee");
    employeeOXDescriptor.setNamespaceResolver(ns);
    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext("/employeeType");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    employeeOXDescriptor.setSchemaReference(schemaReference);
    XMLDirectMapping xmlIdMapping = new XMLDirectMapping();
    xmlIdMapping.setAttributeName("id");
    XMLField idField = new XMLField();
    idField.setName("@id/text()");
    idField.setSchemaType(INT_QNAME);
    xmlIdMapping.setField(idField);
    employeeOXDescriptor.addMapping(xmlIdMapping);
    XMLDirectMapping xmlFirstNameMapping = new XMLDirectMapping();
    xmlFirstNameMapping.setAttributeName("firstName");
    XMLField firstNameField = new XMLField();
    firstNameField.setName("first-name/text()");
    firstNameField.setSchemaType(STRING_QNAME);
    xmlFirstNameMapping.setField(firstNameField);
    employeeOXDescriptor.addMapping(xmlFirstNameMapping);
    XMLDirectMapping xmlLastNameMapping = new XMLDirectMapping();
    xmlLastNameMapping.setAttributeName("lastName");
    XMLField lastNameField = new XMLField();
    lastNameField.setName("last-name/text()");
    lastNameField.setSchemaType(STRING_QNAME);
    xmlLastNameMapping.setField(lastNameField);
    employeeOXDescriptor.addMapping(xmlLastNameMapping);
    XMLCompositeCollectionMapping xmlPhonesMapping = new XMLCompositeCollectionMapping();
    xmlPhonesMapping.setAttributeName("phones");
    xmlPhonesMapping.setReferenceClass(Phone.class);
    xmlPhonesMapping.setXPath("phones/phone");
    employeeOXDescriptor.addMapping(xmlPhonesMapping);
    oxProject.addDescriptor(employeeOXDescriptor);
    XMLDescriptor phoneOXDescriptor = new XMLDescriptor();
    phoneOXDescriptor.setAlias("phone");
    phoneOXDescriptor.setJavaClass(Phone.class);
    phoneOXDescriptor.setDefaultRootElement("phone");
    phoneOXDescriptor.setNamespaceResolver(ns);
    schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext("/phoneType");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    phoneOXDescriptor.setSchemaReference(schemaReference);
    XMLDirectMapping areaCodeMapping = new XMLDirectMapping();
    areaCodeMapping.setAttributeName("areaCode");
    XMLField areaCodeField = new XMLField();
    areaCodeField.setName("area-code/text()");
    areaCodeField.setSchemaType(STRING_QNAME);
    areaCodeMapping.setField(areaCodeField);
    phoneOXDescriptor.addMapping(areaCodeMapping);
    XMLDirectMapping phonenumberMapping = new XMLDirectMapping();
    phonenumberMapping.setAttributeName("phonenumber");
    XMLField phonenumberField = new XMLField();
    phonenumberField.setName("phonenumber/text()");
    phonenumberField.setSchemaType(STRING_QNAME);
    phonenumberMapping.setField(phonenumberField);
    phoneOXDescriptor.addMapping(phonenumberMapping);
    XMLDirectMapping typeMapping = new XMLDirectMapping();
    typeMapping.setAttributeName("type");
    XMLField typeField = new XMLField();
    typeField.setName("type/text()");
    typeField.setSchemaType(STRING_QNAME);
    typeMapping.setField(typeField);
    phoneOXDescriptor.addMapping(typeMapping);
    oxProject.addDescriptor(phoneOXDescriptor);
    XRServiceFactory factory = new XRServiceFactory() {

        Project orProject;

        Project oxProject;

        XRServiceFactory setProject(Project orProject, Project oxProject) {
            this.orProject = orProject;
            this.oxProject = oxProject;
            parentClassLoader = ClassLoader.getSystemClassLoader();
            xrSchemaStream = new ByteArrayInputStream(VEEARRAY_SCHEMA.getBytes());
            return this;
        }

        @Override
        public void buildSessions() {
            DatabaseSession ds = orProject.createDatabaseSession();
            ds.dontLogMessages();
            xrService.setORSession(ds);
            xrService.setXMLContext(new XMLContext(oxProject));
            xrService.setOXSession(xrService.getXMLContext().getSession(0));
        }
    }.setProject(orProject, oxProject);
    XMLContext context = new XMLContext(new DBWSModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(VEEARRAY_XRMODEL));
    xrService = factory.buildService(model);
    if (ddlCreate) {
        try {
            AllTests.runDdl(CREATE_DDL, ddlDebug);
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
}
Also used : Oracle10Platform(org.eclipse.persistence.platform.database.oracle.Oracle10Platform) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) XMLLogin(org.eclipse.persistence.oxm.XMLLogin) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) StringReader(java.io.StringReader) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) ObjectRelationalDataTypeDescriptor(org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) XMLField(org.eclipse.persistence.oxm.XMLField) ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) DBWSModel(org.eclipse.persistence.dbws.DBWSModel) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) StoredProcedureCall(org.eclipse.persistence.queries.StoredProcedureCall) XMLContext(org.eclipse.persistence.oxm.XMLContext) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) SQLException(java.sql.SQLException) Project(org.eclipse.persistence.sessions.Project) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) XRServiceFactory(org.eclipse.persistence.internal.xr.XRServiceFactory) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ByteArrayInputStream(java.io.ByteArrayInputStream) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) ObjectArrayMapping(org.eclipse.persistence.mappings.structures.ObjectArrayMapping) BeforeClass(org.junit.BeforeClass)

Example 3 with DBWSModel

use of org.eclipse.persistence.dbws.DBWSModel in project eclipselink by eclipse-ee4j.

the class OracleObjecttypeTestSuite method setUp.

@BeforeClass
public static void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    final String username = System.getProperty(DATABASE_USERNAME_KEY);
    if (username == null) {
        fail("error retrieving database username");
    }
    final String password = System.getProperty(DATABASE_PASSWORD_KEY);
    if (password == null) {
        fail("error retrieving database password");
    }
    final String url = System.getProperty(DATABASE_URL_KEY);
    if (url == null) {
        fail("error retrieving database url");
    }
    final String driver = System.getProperty(DATABASE_DRIVER_KEY);
    if (driver == null) {
        fail("error retrieving database driver");
    }
    Project orProject = new Project();
    orProject.setName("or-oracleobjecttype");
    ObjectRelationalDataTypeDescriptor addressORDescriptor = new ObjectRelationalDataTypeDescriptor();
    addressORDescriptor.setAlias("address");
    addressORDescriptor.useSoftCacheWeakIdentityMap();
    addressORDescriptor.setJavaClass(Address.class);
    addressORDescriptor.descriptorIsAggregate();
    addressORDescriptor.setStructureName("XR_ADDRESS_TYPE");
    addressORDescriptor.addFieldOrdering("STREET");
    addressORDescriptor.addFieldOrdering("CITY");
    addressORDescriptor.addFieldOrdering("PROV");
    addressORDescriptor.addDirectMapping("street", "STREET");
    addressORDescriptor.addDirectMapping("city", "CITY");
    addressORDescriptor.addDirectMapping("province", "PROV");
    orProject.addDescriptor(addressORDescriptor);
    ObjectRelationalDataTypeDescriptor employeeORDescriptor = new ObjectRelationalDataTypeDescriptor();
    employeeORDescriptor.useSoftCacheWeakIdentityMap();
    employeeORDescriptor.getQueryManager().checkCacheForDoesExist();
    employeeORDescriptor.setAlias("employee");
    employeeORDescriptor.setJavaClass(EmployeeWithAddress.class);
    employeeORDescriptor.addTableName("XR_EMP_ADDR");
    employeeORDescriptor.addPrimaryKeyFieldName("XR_EMP_ADDR.EMPNO");
    orProject.addDescriptor(employeeORDescriptor);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("XR_EMP_ADDR.EMPNO");
    employeeORDescriptor.addMapping(idMapping);
    DirectToFieldMapping firstNameMapping = new DirectToFieldMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setFieldName("XR_EMP_ADDR.FNAME");
    employeeORDescriptor.addMapping(firstNameMapping);
    DirectToFieldMapping lastNameMapping = new DirectToFieldMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setFieldName("XR_EMP_ADDR.LNAME");
    employeeORDescriptor.addMapping(lastNameMapping);
    StructureMapping addressMapping = new StructureMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setReferenceClass(Address.class);
    addressMapping.setFieldName("ADDRESS");
    employeeORDescriptor.addMapping(addressMapping);
    ReadAllQuery readQuery = new ReadAllQuery(EmployeeWithAddress.class);
    readQuery.setName("getEmployeesByProv");
    readQuery.addArgument("X");
    StoredProcedureCall spCall = new StoredProcedureCall();
    spCall.setProcedureName("GET_EMPLOYEES_BY_PROV");
    spCall.addNamedArgument("X", "X", Types.STRUCT, "XR_ADDRESS_TYPE");
    spCall.useNamedCursorOutputAsResultSet("Y");
    readQuery.setCall(spCall);
    employeeORDescriptor.getQueryManager().addQuery("getEmployeesByProv", readQuery);
    ObjectPersistenceWorkbenchXMLProject runtimeProject = new ObjectPersistenceWorkbenchXMLProject();
    XMLTransformationMapping versionMapping = (XMLTransformationMapping) runtimeProject.getDescriptor(Project.class).getMappings().firstElement();
    TransformerBasedFieldTransformation versionTransformer = (TransformerBasedFieldTransformation) versionMapping.getFieldTransformations().get(0);
    Field transformerField = TransformerBasedFieldTransformation.class.getDeclaredField("transformer");
    transformerField.setAccessible(true);
    ConstantTransformer constantTransformer = (ConstantTransformer) transformerField.get(versionTransformer);
    constantTransformer.setValue(CONSTANT_PROJECT_BUILD_VERSION);
    XMLContext context = new XMLContext(runtimeProject);
    XMLMarshaller marshaller = context.createMarshaller();
    Document orProjectDoc = xmlPlatform.createDocument();
    marshaller.marshal(orProject, orProjectDoc);
    Document orProjectXMLDoc = xmlParser.parse(new StringReader(OBJECTTYPE_OR_PROJECT));
    assertTrue("OracleObjecttype java-built OR project not same as XML-built OR project.  Expected:\n" + documentToString(orProjectXMLDoc) + "\nActual:\n" + documentToString(orProjectDoc), comparer.isNodeEqual(orProjectXMLDoc, orProjectDoc));
    NamespaceResolver ns = new NamespaceResolver();
    ns.setDefaultNamespaceURI("urn:oracleobjecttype");
    Project oxProject = new Project();
    oxProject.setName("ox-oracleobjecttype");
    XMLLogin xmlLogin = new XMLLogin();
    xmlLogin.setPlatform(new DOMPlatform());
    xmlLogin.getProperties().remove("user");
    xmlLogin.getProperties().remove("password");
    oxProject.setLogin(xmlLogin);
    XMLDescriptor addressOXDescriptor = new XMLDescriptor();
    addressOXDescriptor.setAlias("address");
    addressOXDescriptor.setJavaClass(Address.class);
    addressOXDescriptor.setDefaultRootElement("address");
    addressOXDescriptor.setNamespaceResolver(ns);
    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext("/addressType");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    addressOXDescriptor.setSchemaReference(schemaReference);
    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    XMLField streetField = new XMLField();
    streetField.setName("street/text()");
    streetField.setSchemaType(STRING_QNAME);
    streetMapping.setField(streetField);
    addressOXDescriptor.addMapping(streetMapping);
    XMLDirectMapping cityMapping = new XMLDirectMapping();
    cityMapping.setAttributeName("city");
    XMLField cityField = new XMLField();
    cityField.setName("city/text()");
    cityField.setSchemaType(STRING_QNAME);
    cityMapping.setField(cityField);
    addressOXDescriptor.addMapping(cityMapping);
    XMLDirectMapping provinceMapping = new XMLDirectMapping();
    provinceMapping.setAttributeName("province");
    XMLField provinceField = new XMLField();
    provinceField.setName("province/text()");
    provinceField.setSchemaType(STRING_QNAME);
    provinceMapping.setField(provinceField);
    addressOXDescriptor.addMapping(provinceMapping);
    oxProject.addDescriptor(addressOXDescriptor);
    XMLDescriptor employeeOXDescriptor = new XMLDescriptor();
    employeeOXDescriptor.setAlias("employee");
    employeeOXDescriptor.setJavaClass(EmployeeWithAddress.class);
    employeeOXDescriptor.setDefaultRootElement("employee");
    employeeOXDescriptor.setNamespaceResolver(ns);
    schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext("/employeeType");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    employeeOXDescriptor.setSchemaReference(schemaReference);
    XMLDirectMapping xmlIdMapping = new XMLDirectMapping();
    xmlIdMapping.setAttributeName("id");
    XMLField idField = new XMLField();
    idField.setName("id/text()");
    idField.setSchemaType(INT_QNAME);
    xmlIdMapping.setField(idField);
    employeeOXDescriptor.addMapping(xmlIdMapping);
    XMLDirectMapping xmlFirstNameMapping = new XMLDirectMapping();
    xmlFirstNameMapping.setAttributeName("firstName");
    XMLField firstNameField = new XMLField();
    firstNameField.setName("first-name/text()");
    firstNameField.setSchemaType(STRING_QNAME);
    xmlFirstNameMapping.setField(firstNameField);
    employeeOXDescriptor.addMapping(xmlFirstNameMapping);
    XMLDirectMapping xmlLastNameMapping = new XMLDirectMapping();
    xmlLastNameMapping.setAttributeName("lastName");
    XMLField lastNameField = new XMLField();
    lastNameField.setName("last-name/text()");
    lastNameField.setSchemaType(STRING_QNAME);
    xmlLastNameMapping.setField(lastNameField);
    employeeOXDescriptor.addMapping(xmlLastNameMapping);
    XMLCompositeObjectMapping xmlAddressMapping = new XMLCompositeObjectMapping();
    xmlAddressMapping.setAttributeName("address");
    xmlAddressMapping.setReferenceClass(Address.class);
    xmlAddressMapping.setXPath("address");
    employeeOXDescriptor.addMapping(xmlAddressMapping);
    oxProject.addDescriptor(employeeOXDescriptor);
    Document oxProjectDoc = xmlPlatform.createDocument();
    marshaller.marshal(oxProject, oxProjectDoc);
    Document oxProjectXMLDoc = xmlParser.parse(new StringReader(OBJECTTYPE_OX_PROJECT));
    assertTrue("OracleObjecttype java-built OX project not same as XML-built OX project.  Expected:\n" + documentToString(oxProjectXMLDoc) + "\nActual:\n" + documentToString(oxProjectDoc), comparer.isNodeEqual(oxProjectXMLDoc, oxProjectDoc));
    XRServiceFactory factory = new XRServiceFactory() {

        XRServiceFactory init() {
            parentClassLoader = ClassLoader.getSystemClassLoader();
            xrSchemaStream = new ByteArrayInputStream(OBJECTTYPE_SCHEMA.getBytes());
            return this;
        }

        @Override
        public void buildSessions() {
            Project orProject = XMLProjectReader.read(new StringReader(OBJECTTYPE_OR_PROJECT), parentClassLoader);
            DatabaseLogin login = new DatabaseLogin();
            login.setUserName(username);
            login.setPassword(password);
            login.setConnectionString(url);
            login.setDriverClassName(driver);
            login.setDatasourcePlatform(new Oracle11Platform());
            login.bindAllParameters();
            orProject.setDatasourceLogin(login);
            DatabaseSession ds = orProject.createDatabaseSession();
            ds.dontLogMessages();
            xrService.setORSession(ds);
            Project oxProject = XMLProjectReader.read(new StringReader(OBJECTTYPE_OX_PROJECT), parentClassLoader);
            xrService.setXMLContext(new XMLContext(oxProject));
            xrService.setOXSession(xrService.getXMLContext().getSession(0));
        }
    }.init();
    context = new XMLContext(new DBWSModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(OBJECTTYPE_XRMODEL));
    xrService = factory.buildService(model);
    if (ddlCreate) {
        try {
            AllTests.runDdl(CREATE_DDL, ddlDebug);
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
}
Also used : TransformerBasedFieldTransformation(org.eclipse.persistence.internal.descriptors.TransformerBasedFieldTransformation) XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) XMLLogin(org.eclipse.persistence.oxm.XMLLogin) Oracle11Platform(org.eclipse.persistence.platform.database.oracle.Oracle11Platform) Document(org.w3c.dom.Document) StructureMapping(org.eclipse.persistence.mappings.structures.StructureMapping) Field(java.lang.reflect.Field) XMLField(org.eclipse.persistence.oxm.XMLField) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) ObjectPersistenceWorkbenchXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) StringReader(java.io.StringReader) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) ObjectRelationalDataTypeDescriptor(org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) XMLField(org.eclipse.persistence.oxm.XMLField) DOMPlatform(org.eclipse.persistence.oxm.platform.DOMPlatform) DBWSModel(org.eclipse.persistence.dbws.DBWSModel) StoredProcedureCall(org.eclipse.persistence.queries.StoredProcedureCall) XMLContext(org.eclipse.persistence.oxm.XMLContext) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) XMLTransformationMapping(org.eclipse.persistence.oxm.mappings.XMLTransformationMapping) ConstantTransformer(org.eclipse.persistence.mappings.transformers.ConstantTransformer) SQLException(java.sql.SQLException) ObjectPersistenceWorkbenchXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject) Project(org.eclipse.persistence.sessions.Project) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) XRServiceFactory(org.eclipse.persistence.internal.xr.XRServiceFactory) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ByteArrayInputStream(java.io.ByteArrayInputStream) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping) BeforeClass(org.junit.BeforeClass)

Example 4 with DBWSModel

use of org.eclipse.persistence.dbws.DBWSModel in project eclipselink by eclipse-ee4j.

the class KeyMappingsTestSuite method setUp.

@BeforeClass
public static void setUp() {
    final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    final String username = System.getProperty(DATABASE_USERNAME_KEY);
    if (username == null) {
        fail("error retrieving database username");
    }
    final String password = System.getProperty(DATABASE_PASSWORD_KEY);
    if (password == null) {
        fail("error retrieving database password");
    }
    final String url = System.getProperty(DATABASE_URL_KEY);
    if (url == null) {
        fail("error retrieving database url");
    }
    final String driver = System.getProperty(DATABASE_DRIVER_KEY);
    if (driver == null) {
        fail("error retrieving database driver");
    }
    XRServiceFactory factory = new XRServiceFactory() {

        @Override
        public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
            parentClassLoader = this.getClass().getClassLoader();
            xrSchemaStream = new ByteArrayInputStream(KEYMAPPINGS_SCHEMA.getBytes());
            return super.buildService(xrServiceModel);
        }

        @Override
        public void buildSessions() {
            XRDynamicClassLoader xrdecl = new XRDynamicClassLoader(parentClassLoader);
            XMLContext context = new XMLContext(new EclipseLinkObjectPersistenceRuntimeXMLProject(), xrdecl);
            XMLUnmarshaller unmarshaller = context.createUnmarshaller();
            Project orProject = (Project) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_OR_PROJECT));
            DatasourceLogin login = new DatabaseLogin();
            login.setUserName(username);
            login.setPassword(password);
            ((DatabaseLogin) login).setConnectionString(url);
            ((DatabaseLogin) login).setDriverClassName(driver);
            Platform platform = new MySQLPlatform();
            ConversionManager conversionManager = platform.getConversionManager();
            if (conversionManager != null) {
                conversionManager.setLoader(xrdecl);
            }
            login.setDatasourcePlatform(platform);
            ((DatabaseLogin) login).bindAllParameters();
            orProject.setDatasourceLogin(login);
            Project oxProject = (Project) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_OX_PROJECT));
            login = (DatasourceLogin) oxProject.getDatasourceLogin();
            if (login != null) {
                platform = login.getDatasourcePlatform();
                if (platform != null) {
                    conversionManager = platform.getConversionManager();
                    if (conversionManager != null) {
                        conversionManager.setLoader(xrdecl);
                    }
                }
            }
            ProjectHelper.fixOROXAccessors(orProject, oxProject);
            xrService.setORSession(orProject.createDatabaseSession());
            xrService.getORSession().dontLogMessages();
            xrService.setXMLContext(new XMLContext(oxProject));
            xrService.setOXSession(xrService.getXMLContext().getSession(0));
        }
    };
    XMLContext context = new XMLContext(new DBWSModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_DBWS));
    xrService = factory.buildService(model);
    if (ddlCreate) {
        try {
            AllTests.runDdl(CREATE_DDL, ddlDebug);
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
}
Also used : DatasourceLogin(org.eclipse.persistence.sessions.DatasourceLogin) DBWSModel(org.eclipse.persistence.dbws.DBWSModel) Platform(org.eclipse.persistence.internal.databaseaccess.Platform) XMLPlatform(org.eclipse.persistence.platform.xml.XMLPlatform) MySQLPlatform(org.eclipse.persistence.platform.database.MySQLPlatform) XMLContext(org.eclipse.persistence.oxm.XMLContext) XRDynamicClassLoader(org.eclipse.persistence.internal.xr.XRDynamicClassLoader) EclipseLinkObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject) Project(org.eclipse.persistence.sessions.Project) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) XRServiceFactory(org.eclipse.persistence.internal.xr.XRServiceFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) XRServiceModel(org.eclipse.persistence.internal.xr.XRServiceModel) StringReader(java.io.StringReader) ConversionManager(org.eclipse.persistence.internal.helper.ConversionManager) EclipseLinkObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) MySQLPlatform(org.eclipse.persistence.platform.database.MySQLPlatform) BeforeClass(org.junit.BeforeClass)

Example 5 with DBWSModel

use of org.eclipse.persistence.dbws.DBWSModel in project eclipselink by eclipse-ee4j.

the class RelationshipsTestSuite method setUp.

@BeforeClass
public static void setUp() {
    final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    final String username = System.getProperty(DATABASE_USERNAME_KEY);
    if (username == null) {
        fail("error retrieving database username");
    }
    final String password = System.getProperty(DATABASE_PASSWORD_KEY);
    if (password == null) {
        fail("error retrieving database password");
    }
    final String url = System.getProperty(DATABASE_URL_KEY);
    if (url == null) {
        fail("error retrieving database url");
    }
    final String driver = System.getProperty(DATABASE_DRIVER_KEY);
    if (driver == null) {
        fail("error retrieving database driver");
    }
    XRServiceFactory factory = new XRServiceFactory() {

        @Override
        public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
            parentClassLoader = this.getClass().getClassLoader();
            xrSchemaStream = new ByteArrayInputStream(RELATIONSHIPS_SCHEMA.getBytes());
            return super.buildService(xrServiceModel);
        }

        @Override
        public void buildSessions() {
            XMLContext context = new XMLContext(new EclipseLinkObjectPersistenceRuntimeXMLProject());
            XMLUnmarshaller unmarshaller = context.createUnmarshaller();
            Project orProject = (Project) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_OR_PROJECT));
            DatabaseLogin login = new DatabaseLogin();
            login.setUserName(username);
            login.setPassword(password);
            login.setConnectionString(url);
            login.setDriverClassName(driver);
            Platform platform = new MySQLPlatform();
            login.setDatasourcePlatform(platform);
            login.bindAllParameters();
            orProject.setDatasourceLogin(login);
            Project oxProject = (Project) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_OX_PROJECT));
            ProjectHelper.fixOROXAccessors(orProject, oxProject);
            xrService.setORSession(orProject.createDatabaseSession());
            xrService.getORSession().dontLogMessages();
            xrService.setXMLContext(new XMLContext(oxProject));
            xrService.setOXSession(xrService.getXMLContext().getSession(0));
        }
    };
    XMLContext context = new XMLContext(new DBWSModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_DBWS));
    xrService = factory.buildService(model);
    if (ddlCreate) {
        try {
            AllTests.runDdl(CREATE_DDL, ddlDebug);
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
}
Also used : DBWSModel(org.eclipse.persistence.dbws.DBWSModel) XMLPlatform(org.eclipse.persistence.platform.xml.XMLPlatform) Platform(org.eclipse.persistence.internal.databaseaccess.Platform) MySQLPlatform(org.eclipse.persistence.platform.database.MySQLPlatform) XMLContext(org.eclipse.persistence.oxm.XMLContext) EclipseLinkObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject) Project(org.eclipse.persistence.sessions.Project) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) DBWSModelProject(org.eclipse.persistence.dbws.DBWSModelProject) XRServiceFactory(org.eclipse.persistence.internal.xr.XRServiceFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) XRServiceModel(org.eclipse.persistence.internal.xr.XRServiceModel) StringReader(java.io.StringReader) EclipseLinkObjectPersistenceRuntimeXMLProject(org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) MySQLPlatform(org.eclipse.persistence.platform.database.MySQLPlatform) BeforeClass(org.junit.BeforeClass)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)5 StringReader (java.io.StringReader)5 DBWSModel (org.eclipse.persistence.dbws.DBWSModel)5 DBWSModelProject (org.eclipse.persistence.dbws.DBWSModelProject)5 XRServiceFactory (org.eclipse.persistence.internal.xr.XRServiceFactory)5 XMLContext (org.eclipse.persistence.oxm.XMLContext)5 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)5 DatabaseLogin (org.eclipse.persistence.sessions.DatabaseLogin)5 Project (org.eclipse.persistence.sessions.Project)5 BeforeClass (org.junit.BeforeClass)4 Platform (org.eclipse.persistence.internal.databaseaccess.Platform)3 XRServiceModel (org.eclipse.persistence.internal.xr.XRServiceModel)3 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)3 SQLException (java.sql.SQLException)2 ConversionManager (org.eclipse.persistence.internal.helper.ConversionManager)2 EclipseLinkObjectPersistenceRuntimeXMLProject (org.eclipse.persistence.internal.sessions.factories.EclipseLinkObjectPersistenceRuntimeXMLProject)2 XRDynamicClassLoader (org.eclipse.persistence.internal.xr.XRDynamicClassLoader)2 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)2 ObjectRelationalDataTypeDescriptor (org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor)2 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)2