* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.aai.dbgen;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.collect.Multimap;
-import com.thinkaurelius.titan.core.*;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
+
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.serialization.db.EdgeRule;
import org.openecomp.aai.serialization.db.EdgeRules;
import org.openecomp.aai.util.AAIConfig;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.collect.Multimap;
+import com.thinkaurelius.titan.core.Cardinality;
+import com.thinkaurelius.titan.core.Multiplicity;
+import com.thinkaurelius.titan.core.PropertyKey;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.schema.TitanManagement;
-import java.util.*;
-public class SchemaGenerator {
+public class SchemaGenerator{
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaGenerator.class);
private static boolean addDefaultCR = true;
}
catch (Exception ex){
LOGGER.error(" ERROR - Could not run AAIConfig.init(). ", ex);
+ System.out.println(" ERROR - Could not run AAIConfig.init(). ");
System.exit(1);
}
}
} catch (AAIException e) {
LOGGER.error("could not get edge rules", e);
+ System.out.println("could not get edge rules");
System.exit(1);
}
for( String label: labels){
if( graphMgmt.containsRelationType(label) ) {
- LOGGER.debug(" EdgeLabel [" + label + "] already existed. ");
+ String dmsg = " EdgeLabel [" + label + "] already existed. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
- LOGGER.debug("Making EdgeLabel: [" + label + "]");
+ String dmsg = "Making EdgeLabel: [" + label + "]";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
graphMgmt.makeEdgeLabel(label).multiplicity(Multiplicity.valueOf("MULTI")).make();
}
}
dbPropName = alias.get();
}
if( graphMgmt.containsRelationType(propName) ){
- LOGGER.debug(" PropertyKey [" + propName + "] already existed in the DB. ");
+ String dmsg = " PropertyKey [" + propName + "] already existed in the DB. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
Class<?> type = obj.getClass(propName);
Cardinality cardinality = Cardinality.SINGLE;
if (process) {
- LOGGER.info("Creating PropertyKey: [" + dbPropName + "], ["+ type.getSimpleName() + "], [" + cardinality + "]");
+ String imsg = "Creating PropertyKey: [" + dbPropName + "], ["+ type.getSimpleName() + "], [" + cardinality + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality).make();
propK = seenProps.get(dbPropName);
}
if (graphMgmt.containsGraphIndex(dbPropName)) {
- LOGGER.debug(" Index [" + dbPropName + "] already existed in the DB. ");
+ String dmsg = " Index [" + dbPropName + "] already existed in the DB. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
if( obj.getIndexedProperties().contains(propName) ){
if( obj.getUniqueProperties().contains(propName) ){
- LOGGER.info("Add Unique index for PropertyKey: [" + dbPropName + "]");
- graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).unique().buildCompositeIndex();
+ imsg = "Add Unique index for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).unique().buildCompositeIndex();
} else {
- LOGGER.info("Add index for PropertyKey: [" + dbPropName + "]");
- graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).buildCompositeIndex();
+ imsg = "Add index for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).buildCompositeIndex();
}
} else {
- LOGGER.info("No index added for PropertyKey: [" + dbPropName + "]");
+ imsg = "No index added for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
}
}
}
}
}
- LOGGER.info("-- About to call graphMgmt commit");
+ String imsg = "-- About to call graphMgmt commit";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+
graphMgmt.commit();
}// End of loadSchemaIntoTitan()