Package com.buschmais.jqassistant.plugin.jpa2.api.model

Examples of com.buschmais.jqassistant.plugin.jpa2.api.model.PersistenceUnitDescriptor


        scanDirectory(CLASSPATH, new File(getClassesDirectory(JpaEntity.class), "full"));
        store.beginTransaction();
        TestResult testResult = query("MATCH (p:Jpa:Persistence) RETURN p");
        assertThat(testResult.getRows().size(), equalTo(1));
        List<? super PersistenceDescriptor> persistenceDescriptors = testResult.getColumn("p");
        PersistenceDescriptor persistenceDescriptor = (PersistenceDescriptor) persistenceDescriptors.get(0);
        assertThat(persistenceDescriptor.getVersion(), equalTo("2.0"));
        Set<PersistenceUnitDescriptor> persistenceUnits = persistenceDescriptor.getContains();
        assertThat(persistenceUnits, hasItem(PersistenceUnitMatcher.persistenceUnitDescriptor("persistence-unit")));
        store.commitTransaction();
    }
View Full Code Here


        scanDirectory(CLASSPATH, new File(getClassesDirectory(JpaEntity.class), "minimal"));
        store.beginTransaction();
        TestResult testResult = query("MATCH (p:Jpa:Persistence) RETURN p");
        assertThat(testResult.getRows().size(), equalTo(1));
        List<? super PersistenceDescriptor> persistenceDescriptors = testResult.getColumn("p");
        PersistenceDescriptor persistenceDescriptor = (PersistenceDescriptor) persistenceDescriptors.get(0);
        assertThat(persistenceDescriptor.getVersion(), equalTo("2.0"));
        Set<PersistenceUnitDescriptor> persistenceUnits = persistenceDescriptor.getContains();
        assertThat(persistenceUnits, hasItem(PersistenceUnitMatcher.persistenceUnitDescriptor("persistence-unit")));
        store.commitTransaction();
    }
View Full Code Here

            persistence = unmarshaller.unmarshal(new StreamSource(item), Persistence.class).getValue();
        } catch (JAXBException e) {
            throw new IOException("Cannot read model descriptor.", e);
        }
        Store store = getStore();
        PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
        persistenceDescriptor.setVersion(persistence.getVersion());
        // Create model units
        for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
            PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
            persistenceUnitDescriptor.setName(persistenceUnit.getName());
            PersistenceUnitTransactionType transactionType = persistenceUnit.getTransactionType();
            if (transactionType != null) {
                persistenceUnitDescriptor.setTransactionType(transactionType.name());
            }
            persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
            persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
            persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
            persistenceUnitDescriptor.setProvider(persistenceUnit.getProvider());
            PersistenceUnitValidationModeType validationMode = persistenceUnit.getValidationMode();
            if (validationMode != null) {
                persistenceUnitDescriptor.setValidationMode(validationMode.name());
            }
            PersistenceUnitCachingType sharedCacheMode = persistenceUnit.getSharedCacheMode();
            if (sharedCacheMode != null) {
                persistenceUnitDescriptor.setSharedCacheMode(sharedCacheMode.name());
            }
            for (String clazz : persistenceUnit.getClazz()) {
                TypeDescriptor typeDescriptor = descriptorResolverFactory.getTypeDescriptorResolver().resolve(clazz);
                persistenceUnitDescriptor.getContains().add(typeDescriptor);
            }
            // Create persistence unit properties
            PersistenceUnit.Properties properties = persistenceUnit.getProperties();
            if (properties != null) {
                for (Property property : properties.getProperty()) {
                    PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
                    propertyDescriptor.setName(property.getName());
                    propertyDescriptor.setValue(property.getValue());
                    persistenceUnitDescriptor.getProperties().add(propertyDescriptor);
                }
            }
            // Add model unit to model descriptor
            persistenceDescriptor.getContains().add(persistenceUnitDescriptor);
        }
        persistenceDescriptor.setFileName(path);
        return asList(persistenceDescriptor);
    }
View Full Code Here

        scanDirectory(CLASSPATH, new File(getClassesDirectory(JpaEntity.class), "full"));
        store.beginTransaction();
        TestResult testResult = query("MATCH (pu:Jpa:PersistenceUnit) RETURN pu");
        assertThat(testResult.getRows().size(), equalTo(1));
        List<? super PersistenceUnitDescriptor> persistenceUnitDescriptors = testResult.getColumn("pu");
        PersistenceUnitDescriptor persistenceUnitDescriptor = (PersistenceUnitDescriptor) persistenceUnitDescriptors.get(0);
        assertThat(persistenceUnitDescriptor.getName(), equalTo("persistence-unit"));
        assertThat(persistenceUnitDescriptor.getTransactionType(), equalTo("RESOURCE_LOCAL"));
        assertThat(persistenceUnitDescriptor.getDescription(), equalTo("description"));
        assertThat(persistenceUnitDescriptor.getJtaDataSource(), equalTo("jtaDataSource"));
        assertThat(persistenceUnitDescriptor.getNonJtaDataSource(), equalTo("nonJtaDataSource"));
        assertThat(persistenceUnitDescriptor.getProvider(), equalTo("provider"));
        assertThat(persistenceUnitDescriptor.getValidationMode(), equalTo("AUTO"));
        assertThat(persistenceUnitDescriptor.getSharedCacheMode(), equalTo("ENABLE_SELECTIVE"));
        assertThat(persistenceUnitDescriptor.getContains(), hasItem(typeDescriptor(JpaEntity.class)));
        Matcher<? super PropertyDescriptor> valueMatcher = valueDescriptor("stringProperty", equalTo("stringValue"));
        assertThat(persistenceUnitDescriptor.getProperties(), hasItem(valueMatcher));
        store.commitTransaction();
    }
View Full Code Here

        Store store = getStore();
        PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
        persistenceDescriptor.setVersion(persistence.getVersion());
        // Create model units
        for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
            PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
            persistenceUnitDescriptor.setName(persistenceUnit.getName());
            PersistenceUnitTransactionType transactionType = persistenceUnit.getTransactionType();
            if (transactionType != null) {
                persistenceUnitDescriptor.setTransactionType(transactionType.name());
            }
            persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
            persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
            persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
            persistenceUnitDescriptor.setProvider(persistenceUnit.getProvider());
            PersistenceUnitValidationModeType validationMode = persistenceUnit.getValidationMode();
            if (validationMode != null) {
                persistenceUnitDescriptor.setValidationMode(validationMode.name());
            }
            PersistenceUnitCachingType sharedCacheMode = persistenceUnit.getSharedCacheMode();
            if (sharedCacheMode != null) {
                persistenceUnitDescriptor.setSharedCacheMode(sharedCacheMode.name());
            }
            for (String clazz : persistenceUnit.getClazz()) {
                TypeDescriptor typeDescriptor = descriptorResolverFactory.getTypeDescriptorResolver().resolve(clazz);
                persistenceUnitDescriptor.getContains().add(typeDescriptor);
            }
            // Create persistence unit properties
            PersistenceUnit.Properties properties = persistenceUnit.getProperties();
            if (properties != null) {
                for (Property property : properties.getProperty()) {
                    PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
                    propertyDescriptor.setName(property.getName());
                    propertyDescriptor.setValue(property.getValue());
                    persistenceUnitDescriptor.getProperties().add(propertyDescriptor);
                }
            }
            // Add model unit to model descriptor
            persistenceDescriptor.getContains().add(persistenceUnitDescriptor);
        }
View Full Code Here

      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      persistence = unmarshaller.unmarshal(streamSource, Persistence.class).getValue();
    } catch (JAXBException e) {
      throw new IOException("Cannot read model descriptor.", e);
    }
    PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
    persistenceDescriptor.setName(streamSource.getSystemId());
    persistenceDescriptor.setVersion(persistence.getVersion());
    // Create model units
    for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
      PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
      persistenceUnitDescriptor.setName(persistenceUnit.getName());
      persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
      persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
      persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
      persistenceUnitDescriptor.setProvider(persistenceUnit.getProvider());
      persistenceUnitDescriptor.setValidationMode(persistenceUnit.getValidationMode().name());
      persistenceUnitDescriptor.setSharedCacheMode(persistenceUnit.getSharedCacheMode().name());
      for (String clazz : persistenceUnit.getClazz()) {
        TypeDescriptor typeDescriptor = descriptorResolverFactory.getTypeDescriptorResolver().resolve(clazz);
        persistenceUnitDescriptor.getContains().add(typeDescriptor);
      }
      // Create model unit properties
      for (Property property : persistenceUnit.getProperties().getProperty()) {
        PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
        propertyDescriptor.setName(property.getName());
        propertyDescriptor.setValue(property.getValue());
        persistenceUnitDescriptor.getProperties().add(propertyDescriptor);
      }
      // Add model unit to model descriptor
      persistenceDescriptor.getContains().add(persistenceUnitDescriptor);
    }
    return persistenceDescriptor;
  }
View Full Code Here

    PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
    persistenceDescriptor.setName(streamSource.getSystemId());
    persistenceDescriptor.setVersion(persistence.getVersion());
    // Create model units
    for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
      PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
      persistenceUnitDescriptor.setName(persistenceUnit.getName());
      persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
      persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
      persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
      persistenceUnitDescriptor.setProvider(persistenceUnit.getProvider());
      persistenceUnitDescriptor.setValidationMode(persistenceUnit.getValidationMode().name());
      persistenceUnitDescriptor.setSharedCacheMode(persistenceUnit.getSharedCacheMode().name());
      for (String clazz : persistenceUnit.getClazz()) {
        TypeDescriptor typeDescriptor = descriptorResolverFactory.getTypeDescriptorResolver().resolve(clazz);
        persistenceUnitDescriptor.getContains().add(typeDescriptor);
      }
      // Create model unit properties
      for (Property property : persistenceUnit.getProperties().getProperty()) {
        PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
        propertyDescriptor.setName(property.getName());
        propertyDescriptor.setValue(property.getValue());
        persistenceUnitDescriptor.getProperties().add(propertyDescriptor);
      }
      // Add model unit to model descriptor
      persistenceDescriptor.getContains().add(persistenceUnitDescriptor);
    }
    return persistenceDescriptor;
View Full Code Here

TOP

Related Classes of com.buschmais.jqassistant.plugin.jpa2.api.model.PersistenceUnitDescriptor

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.