Search in sources :

Example 21 with SchemaVersion

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

the class EdgeIngestorTest method getParentRulesNoneInVersionTest.

@Test
public void getParentRulesNoneInVersionTest() {
    Multimap<String, EdgeRule> results = edgeIngestor.getParentRules("baz", new SchemaVersion("v11"));
    assertTrue(results.isEmpty());
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with SchemaVersion

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

the class CreateWidgetModels method main.

/**
 * The main method.
 *
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {
    String _apiVersion = AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP);
    String widgetJsonDir = null;
    String modelVersion = null;
    if (args.length > 0) {
        if (args[0] != null) {
            _apiVersion = args[0];
        }
        if (args[1] != null) {
            widgetJsonDir = args[1];
        }
        if (args[2] != null) {
            modelVersion = args[2];
        }
    }
    if (widgetJsonDir == null) {
        System.err.println("You must specify a directory for widgetModelJson");
        System.exit(0);
    }
    if (modelVersion == null) {
        System.err.println("You must specify a modelVersion");
        System.exit(0);
    }
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext("org.onap.aai.config", "org.onap.aai.setup");
    LoaderFactory loaderFactory = ctx.getBean(LoaderFactory.class);
    Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion(_apiVersion));
    // iterate the collection of resources
    ArrayList<String> processedWidgets = new ArrayList<String>();
    for (Entry<String, Introspector> aaiResEnt : loader.getAllObjects().entrySet()) {
        Introspector meObject = loader.introspectorFromName("model");
        // no need for a ModelVers DynamicEntity
        Introspector aaiRes = aaiResEnt.getValue();
        if (!(aaiRes.isContainer() || aaiRes.getName().equals("aai-internal"))) {
            String resource = aaiRes.getName();
            if (processedWidgets.contains(resource)) {
                continue;
            }
            Set<String> introspectorProperties = aaiRes.getProperties();
            if (!(introspectorProperties.contains("model-version-id") && introspectorProperties.contains("model-invariant-id"))) {
                System.out.println(aaiRes.getDbName() + " does not contain model properties so skipping");
            }
            processedWidgets.add(resource);
            String widgetName = resource;
            String filePathString = widgetJsonDir + "/" + widgetName + "-" + modelVersion + ".json";
            File f = new File(filePathString);
            String filePathString2 = widgetJsonDir + "/../widget-model-json-old/" + widgetName + "-" + modelVersion + ".json";
            File f2 = new File(filePathString2);
            if (!f.exists() && !f.isDirectory()) {
                if (f2.exists()) {
                    System.out.println("Using old file for " + resource + ".");
                    meObject = loader.unmarshal("model", new StreamSource(f2).getReader().toString());
                    // override, some of them are wrong
                    meObject.setValue("model-version", modelVersion);
                } else {
                    System.out.println("Making new file for " + resource + ".");
                    meObject.setValue("model-invariant-id", UUID.randomUUID().toString());
                    meObject.setValue("model-type", "widget");
                    Introspector mevObject = loader.introspectorFromName("model-ver");
                    Introspector mevsObject = loader.introspectorFromName("model-vers");
                    mevObject.setValue("model-version-id", UUID.randomUUID().toString());
                    mevObject.setValue("model-version", modelVersion);
                    mevObject.setValue("model-Name", widgetName);
                    // make a list of dynamic Entities
                    List<Object> mevsList = new ArrayList<>();
                    // add this one, it will be the only one in the list in this case
                    mevsList.add(mevObject.getUnderlyingObject());
                    mevsObject.setValue("model-ver", mevsList);
                    // Have to figure out how to add my mev object to the mevsObject,
                    // the modelVers is a list of dynamic entities so we can just attach the array here
                    meObject.setValue("model-vers", mevsObject.getUnderlyingObject());
                }
                // put it out as JSON
                PrintWriter out = new PrintWriter(f);
                out.println(meObject.marshal(true));
                out.close();
            } else {
                System.out.println("File already exists for " + resource + ".  Skipping.");
            }
        }
    }
    System.exit(0);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SchemaVersion(org.onap.aai.setup.SchemaVersion) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) Loader(org.onap.aai.introspection.Loader) Introspector(org.onap.aai.introspection.Introspector) LoaderFactory(org.onap.aai.introspection.LoaderFactory) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 23 with SchemaVersion

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

the class LegacyQueryTest method setup.

public void setup() {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine)

Example 24 with SchemaVersion

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

the class RelationshipGremlinQueryTest method setup.

@Before
public void setup() {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 25 with SchemaVersion

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

the class RelationshipQueryTest method setup.

@Before
public void setup() {
    version = new SchemaVersion("v10");
    dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

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