本文整理汇总了Java中com.tinkerpop.blueprints.impls.orient.OrientVertexType类的典型用法代码示例。如果您正苦于以下问题:Java OrientVertexType类的具体用法?Java OrientVertexType怎么用?Java OrientVertexType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrientVertexType类属于com.tinkerpop.blueprints.impls.orient包,在下文中一共展示了OrientVertexType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Auditor
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
public Auditor(Transaction t, String user) {
this.transaction = t;
this.auditUser = user;
// verificar que la clase de auditorías exista
if (this.transaction.getDBClass(this.ODBAUDITLOGVERTEXCLASS) == null) {
OrientVertexType olog = this.transaction.getGraphdb().createVertexType(this.ODBAUDITLOGVERTEXCLASS);
olog.createProperty("rid", OType.STRING);
olog.createProperty("timestamp", OType.DATETIME);
olog.createProperty("user", OType.STRING);
olog.createProperty("action", OType.STRING);
olog.createProperty("label", OType.STRING);
olog.createProperty("log", OType.STRING);
this.transaction.commit();
}
}
示例2: checkIndexUniqueness
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public <T extends MeshElement> T checkIndexUniqueness(String indexName, T element, Object key) {
FramedGraph graph = Tx.getActive().getGraph();
OrientBaseGraph orientBaseGraph = unwrapCurrentGraph();
OrientVertexType vertexType = orientBaseGraph.getVertexType(element.getClass().getSimpleName());
if (vertexType != null) {
OIndex<?> index = vertexType.getClassIndex(indexName);
if (index != null) {
Object recordId = index.get(key);
if (recordId != null) {
if (recordId.equals(element.getElement().getId())) {
return null;
} else {
return (T) graph.getFramedVertexExplicit(element.getClass(), recordId);
}
}
}
}
return null;
}
示例3: setUp
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public void setUp() {
OGlobalConfiguration.USE_WAL.setValue(true);
super.setUp();
final OrientVertexType v1 = graph.createVertexType("V1");
final OrientVertexType v2 = graph.createVertexType("V2");
final OrientEdgeType edgeType = graph.createEdgeType("Friend");
edgeType.createProperty("in", OType.LINK, v2);
edgeType.createProperty("out", OType.LINK, v1);
// ASSURE NOT DUPLICATES
edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");
graph.addVertex("class:V2").setProperty("name", "Luca");
graph.commit();
}
示例4: addVertrexType
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
public static void addVertrexType(OrientBaseGraph graph, Class<?> clasz) {
if (clasz.isAnnotationPresent(DatabaseVertrex.class)) {
//Map<String, DatabaseProperty> mapSchemaProperty = new HashMap<String, DatabaseProperty>();
DatabaseVertrex classAnotation = clasz.getAnnotation(DatabaseVertrex.class);
String className = clasz.getSimpleName();
if(StringUtils.isNotBlank(classAnotation.name())) {
className = classAnotation.name();
}
OrientVertexType oClass = graph.getVertexType(className);
Class<?> parentClass = clasz.getSuperclass();
while(!parentClass.isAnnotationPresent(DatabaseVertrex.class) && (parentClass.getSuperclass() != null)) {
parentClass = parentClass.getSuperclass();
}
OrientVertexType oParentClass = graph.getVertexType(parentClass.getSimpleName());
if (parentClass.getSimpleName().equals(Object.class.getSimpleName())) {
oParentClass = graph.getVertexBaseType();
}
if (oClass == null) {
logger.warn("Add Vertrex @" + className + " child of @" + oParentClass);
graph.createVertexType(className, oParentClass.getName());
} else {
if (logger.isDebugEnabled())
logger.debug("Vertrex @" + className + " exist, child of @" + oParentClass);
}
}
}
示例5: getType
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
public final String getType() {
OrientVertexType type;
try {
type = this.getOrientVertex().getType();
} catch (Exception e) {
logger.trace("getType() is null -> 2nd chance! [" + e.getMessage() + "]");
this.reload();
type = this.getOrientVertex().getType();
}
return type.getName();
}
示例6: initialize
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public void initialize() {
final OrientBaseGraph db = context.getConnection();
/**
* Avoid creating scheme if table already exist.
* Look method implementation: internally it use document api the same way as it was used in
* document sample.
*/
if (db.getVertexType(CLASS_NAME) != null) {
return;
}
/**
* In database scheme the only difference with other apis would be that
* Sample class would extend "V" in scheme (which marks type as Vertex type).
*/
final OrientVertexType vtype = db.createVertexType(CLASS_NAME);
vtype.createProperty("name", OType.STRING);
vtype.createProperty("amount", OType.INTEGER);
// registration of graph type is not mandatory (orient will create it on-the-fly)
// but with warning
// also note that edge name is case-insensitive and so used as "belongsTo" everywhere in code
db.createEdgeType("BelongsTo");
}
示例7: addVertexType
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public void addVertexType(Class<?> clazzOfVertex, Class<?> superClazzOfVertex) {
if (log.isDebugEnabled()) {
log.debug("Adding vertex type for class {" + clazzOfVertex.getName() + "}");
}
OrientGraphNoTx noTx = factory.getNoTx();
try {
OrientVertexType vertexType = noTx.getVertexType(clazzOfVertex.getSimpleName());
if (vertexType == null) {
String superClazz = "V";
if (superClazzOfVertex != null) {
superClazz = superClazzOfVertex.getSimpleName();
}
vertexType = noTx.createVertexType(clazzOfVertex.getSimpleName(), superClazz);
} else {
// Update the existing vertex type and set the super class
if (superClazzOfVertex != null) {
OrientVertexType superType = noTx.getVertexType(superClazzOfVertex.getSimpleName());
if (superType == null) {
throw new RuntimeException("The supertype for vertices of type {" + clazzOfVertex + "} can't be set since the supertype {"
+ superClazzOfVertex.getSimpleName() + "} was not yet added to orientdb.");
}
vertexType.setSuperClass(superType);
}
}
} finally {
noTx.shutdown();
}
}
示例8: removeVertexType
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public void removeVertexType(String typeName) {
if (log.isDebugEnabled()) {
log.debug("Removing vertex type with name {" + typeName + "}");
}
OrientGraphNoTx noTx = factory.getNoTx();
try {
OrientVertexType type = noTx.getVertexType(typeName);
if (type != null) {
noTx.dropVertexType(typeName);
}
} finally {
noTx.shutdown();
}
}
示例9: addVertexIndex
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@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 = factory.getNoTx();
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 = convertType(fieldType);
OType subType = convertToSubType(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();
}
}
示例10: setupTypesAndIndices
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
private static void setupTypesAndIndices(OrientGraphFactory factory2) {
OrientGraph g = factory.getTx();
try {
// g.setUseClassForEdgeLabel(true);
g.setUseLightweightEdges(false);
g.setUseVertexFieldsForEdgeLabels(false);
} finally {
g.shutdown();
}
try {
g = factory.getTx();
OrientEdgeType e = g.createEdgeType("HAS_ITEM");
e.createProperty("in", OType.LINK);
e.createProperty("out", OType.LINK);
e.createIndex("e.has_item", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "out", "in");
OrientVertexType v = g.createVertexType("root", "V");
v.createProperty("name", OType.STRING);
v = g.createVertexType("item", "V");
v.createProperty("name", OType.STRING);
v.createIndex("item", OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX, "name");
} finally {
g.shutdown();
}
}
示例11: getConfiguration
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@Override
public ODocument getConfiguration() {
return new ODocument().fromJSON("{parameters:[" + getCommonConfigurationParameters() + ","
+ "{class:{optional:true,description:'Vertex class name to assign. Default is " + OrientVertexType.CLASS_NAME + "'}}"
+ ",skipDuplicates:{optional:true,description:'Vertices with duplicate keys are skipped', default:false}" + "]"
+ ",input:['OrientVertex','ODocument'],output:'OrientVertex'}");
}
示例12: init
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@BeforeClass
public void init() {
initDB();
graph = new OrientGraph((ODatabaseDocumentTx) databaseDocumentTx, false);
OrientVertexType type = graph.createVertexType("City");
type.createProperty("latitude", OType.DOUBLE);
type.createProperty("longitude", OType.DOUBLE);
type.createProperty("name", OType.STRING);
databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
示例13: init
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
@BeforeClass
public void init() {
initDB();
OrientGraph graph = new OrientGraph((ODatabaseDocumentTx) databaseDocumentTx, false);
OrientVertexType type = graph.createVertexType("City");
type.createProperty("name", OType.STRING);
databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
示例14: createSchema
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
protected void createSchema()
{
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@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;
}
});
}
示例15: saveDataModule
import com.tinkerpop.blueprints.impls.orient.OrientVertexType; //导入依赖的package包/类
private Module saveDataModule(Module module) {
DataModel dataModel;
if (module.getModel() == null) {
dataModel = DataModel.createDefault();
dataModel.setName(module.getName());
module.setModel(HybridbpmCoreUtil.objectToJson(dataModel));
} else {
dataModel = HybridbpmCoreUtil.jsonToObject(module.getModel(), DataModel.class);
}
module.setCode(HybridbpmCoreUtil.createDataCode(dataModel));
OrientGraphNoTx graphNoTx = getOrientGraphNoTx();
OrientVertexType vertexType;
if (!graphNoTx.getRawGraph().getMetadata().getSchema().existsClass(module.getName())) {
vertexType = graphNoTx.createVertexType(module.getName());
} else {
vertexType = graphNoTx.getVertexType(module.getName());
}
for (FieldModel fieldModel : dataModel.getFields()) {
createProperty(vertexType, fieldModel, graphNoTx);
}
// TODO: check if we need to remove or not
// for (OProperty property : vertexType.declaredProperties()) {
// try {
// if (!dataModel.containsField(property.getName())) {
// vertexType.dropProperty(property.getName());
// }
// } catch (Exception ex) {
// Logger.getLogger(DevelopmentAPI.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
// }
// }
graphNoTx.commit();
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
module.setUpdateDate(new Date());
module = database.save(module);
database.commit();
module = detach(module);
}
regenerateGroovySources();
return module;
}