To determine if a property exists:
String clazz = "someClass";
boolean propertyExists;
OClass oClass = graph.getRawGraph().getMetadata().getSchema().
getClass(clazz);
if (oClass != null) {
OProperty oProperty = oClass.getProperty(key);
propertyExists = (oProperty != null);
} else {
propertyExists = false;
}
On Sunday, August 31, 2014 3:51:01 AM UTC-4, Curtis Mosters wrote:
>
> No I want to extend the Schema. Not adding property values on one Vertex =)
>
> I think about something like noTxGraph.createPropertyType(
> className,propertyName);
>
> Maybe there is already some cool way to do this. But unfindable in the doc
> =/
>
> Am Samstag, 30. August 2014 17:45:13 UTC+2 schrieb Epl:
>>
>> One way of finding all the property is by key name. so on vertex 'v' you
>> can call
>>
>> v.getPropertyKeys which will return all keys of that class. Which may be
>> efficient too because you have access to that vertex already. Same I
>> believe you can do edges too that also extends Element class where this
>> method is defined.
>>
>> On Saturday, August 30, 2014 10:03:44 AM UTC+1, Curtis Mosters wrote:
>>>
>>> Well checking if a class exists is really easy
>>>
>>> OrientGraphNoTx noTxGraph = factoryGraph.getNoTx();
>>> OSchema schema = db.getMetadata().getSchema();
>>> if (!schema.existsClass(className)) {
>>> noTxGraph.createVertexType(className);
>>> }
>>>
>>>
>>>
>>> but I cannot find a ways to check this on a property. The only way is
>>> with searching for the class, saving it, and than go through all the
>>> property and match it with the searched property.
>>>
>>> Is there a ways to do this much easier, like with the Schema above?
>>>
>>> And for sure I just can put a try catch but I don't an exception thrown,
>>> because it's easy to avoid.
>>>
>>> Thank you.
>>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.