status.createProperty("host", OType.STRING); status.createProperty("app", OType.STRING); status.createProperty("map", OType.EMBEDDEDMAP); config.createProperty("configId", OType.STRING); config.createProperty("description", OType.STRING); config.createProperty("properties", OType.EMBEDDEDMAP); config.createProperty("createDate", OType.DATETIME); config.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("configId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Config")); hostConfig.createProperty("host", OType.STRING); hostConfig.createProperty("configId", OType.STRING); hostConfig.createProperty("description", OType.STRING); hostConfig.createProperty("properties", OType.EMBEDDEDMAP); hostConfig.createProperty("createDate", OType.DATETIME); hostConfig.createProperty("updateDate", OType.DATETIME); hostConfig.createIndex("configHostIdIdx", OClass.INDEX_TYPE.UNIQUE, "host", "configId"); role.createProperty("roleId", OType.STRING); role.createProperty("host", OType.STRING); role.createProperty("description", OType.STRING); role.createProperty("createDate", OType.DATETIME); role.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("roleId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Role")); user.createProperty("host", OType.STRING); user.createProperty("userId", OType.STRING); user.createProperty("email", OType.STRING);
@Override public void addVertexIndex(String indexName, Class<?> clazzOfVertices, boolean unique, String fieldKey, FieldType fieldType) { if (log.isDebugEnabled()) { log.debug("Adding vertex index for class {" + clazzOfVertices.getName() + "}"); } OrientGraphNoTx noTx = rawNoTx(); try { String name = clazzOfVertices.getSimpleName(); OrientVertexType v = noTx.getVertexType(name); if (v == null) { throw new RuntimeException("Vertex type {" + name + "} is unknown. Can't create index {" + indexName + "}"); } if (v.getProperty(fieldKey) == null) { OType type = toType(fieldType); OType subType = toSubType(fieldType); if (subType != null) { v.createProperty(fieldKey, type, subType); } else { v.createProperty(fieldKey, type); } } if (v.getClassIndex(indexName) == null) { v.createIndex(indexName, unique ? OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString() : OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { fieldKey }); } } finally { noTx.shutdown(); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Object call(final OrientBaseGraph g) { OrientVertexType v = g.getVertexBaseType(); if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later v.createProperty(NODE_ID, OType.INTEGER); g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter( "keytype", "INTEGER")); v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG); v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG); OrientEdgeType similar = g.createEdgeType(SIMILAR); similar.createProperty("out", OType.LINK, v); similar.createProperty("in", OType.LINK, v); g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); } return null; } });