Search in sources :

Example 26 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class UniqueRelationshipQueryTest method setup.

/**
 * Setup.
 *
 * @throws JAXBException the JAXB exception
 */
@Before
public void setup() throws JAXBException {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
    unmarshaller = context.createUnmarshaller();
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
    unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 27 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class UniqueURIQueryTest method parentQuery.

/**
 * Parent query.
 *
 * @throws UnsupportedEncodingException the unsupported encoding exception
 * @throws AAIException the AAI exception
 */
@Test
public void parentQuery() throws UnsupportedEncodingException, AAIException {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
    URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build();
    String key = "complex/key1";
    QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
    GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
    String parentResultType = "";
    String resultType = "complex";
    String containerType = "";
    testSet(query, expected, expected, parentResultType, resultType, containerType);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) URI(java.net.URI) Test(org.junit.Test)

Example 28 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class NodeIngestor method translateAll.

private void translateAll(Translator translator) throws ExceptionInInitializerError {
    if (translator instanceof ConfigTranslator) {
        this.localSchema = "true";
    }
    Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
    /*
         * Set this to default schemaVersion
         */
    this.schemaVersions = translator.getSchemaVersions();
    List<SchemaVersion> schemaVersionList = translator.getSchemaVersions().getVersions();
    try {
        for (SchemaVersion version : schemaVersionList) {
            LOGGER.debug("Version being processed" + version);
            List<InputStream> inputStreams = retrieveOXM(version, translator);
            LOGGER.debug("Retrieved OXMs from SchemaService");
            /*
                 * IOUtils.copy and copy the inputstream
                 */
            if (inputStreams.isEmpty()) {
                continue;
            }
            final DynamicJAXBContext ctx = ingest(inputStreams);
            versionContextMap.put(version, ctx);
            setAllTypesAndProperties(version, inputStreams);
            schemaPerVersion.put(version, createCombinedSchema(inputStreams, version, retrieveLocalSchema));
        }
    } catch (JAXBException | ParserConfigurationException | SAXException | IOException e) {
        throw new ExceptionInInitializerError(e);
    }
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) DynamicJAXBContext(org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigTranslator(org.onap.aai.setup.ConfigTranslator)

Example 29 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class OxmEdgeRulesLoader method loadModels.

/**
 * Finds all DB Edge Rules and Edge Properties files for all OXM models.
 *
 * @throws SchemaProviderException
 * @throws SchemaProviderException
 */
public static synchronized void loadModels() throws SchemaProviderException {
    Map<String, File> propFiles = edgePropertyFiles(edgePropsConfiguration);
    if (logger.isDebugEnabled()) {
        logger.debug("Loading DB Edge Rules");
    }
    for (String version : OxmSchemaLoader.getLoadedOXMVersions()) {
        try {
            SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream().filter(s -> s.toString().equalsIgnoreCase(version)).findAny().orElse(null);
            loadModel(schemaVersion, edgeIngestor, propFiles);
        } catch (IOException | EdgeRuleNotFoundException e) {
            throw new SchemaProviderException(e.getMessage(), e);
        }
    }
}
Also used : EdgeRuleNotFoundException(org.onap.aai.edges.exceptions.EdgeRuleNotFoundException) SchemaVersion(org.onap.aai.setup.SchemaVersion) IOException(java.io.IOException) SchemaProviderException(org.onap.aai.schemaif.SchemaProviderException) File(java.io.File)

Example 30 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class OxmEdgeRulesLoader method loadModels.

/**
 * Loads DB Edge Rules and Edge Properties for a given version.
 *
 * @throws SchemaProviderException
 */
public static synchronized void loadModels(String v) throws SchemaProviderException {
    Map<String, File> propFiles = edgePropertyFiles(edgePropsConfiguration);
    if (logger.isDebugEnabled()) {
        logger.debug("Loading DB Edge Rules ");
    }
    try {
        SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream().filter(s -> s.toString().equalsIgnoreCase(v)).findAny().orElse(null);
        loadModel(schemaVersion, edgeIngestor, propFiles);
    } catch (IOException | EdgeRuleNotFoundException e) {
        throw new SchemaProviderException(e.getMessage());
    }
}
Also used : EdgeRuleNotFoundException(org.onap.aai.edges.exceptions.EdgeRuleNotFoundException) SchemaVersion(org.onap.aai.setup.SchemaVersion) IOException(java.io.IOException) SchemaProviderException(org.onap.aai.schemaif.SchemaProviderException) File(java.io.File)

Aggregations

SchemaVersion (org.onap.aai.setup.SchemaVersion)78 Test (org.junit.Test)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 ArrayList (java.util.ArrayList)19 List (java.util.List)16 Loader (org.onap.aai.introspection.Loader)13 TreeMap (java.util.TreeMap)12 AAIException (org.onap.aai.exceptions.AAIException)9 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)8 Introspector (org.onap.aai.introspection.Introspector)7 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)7 URI (java.net.URI)6 DynamicJAXBContext (org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext)6 QueryParser (org.onap.aai.parsers.query.QueryParser)5 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Before (org.junit.Before)4 ModelType (org.onap.aai.introspection.ModelType)4 URIToObject (org.onap.aai.parsers.uri.URIToObject)4 DBRequest (org.onap.aai.rest.db.DBRequest)4