Hi Valentin,
You are right. In OrientDb concept of classes are more comprehensive.
By default you have 2 classes:
- V for vertexes;
- E for edges.
When you create new vertex type you create a class that extends V, and in
much in the same manner when you create edge type you create a class that
extends E. In the deeper level this classes doesn't differ except they have
different super-classes.
For your case, the simplest way to solve the problem to use prefix.
Something like:
public enum Relationship {
USER, TAGS, PROPERTIES,
FOLDERVERSION, ITEMVERSION, //used for versioned relations
FOLDER, ITEM, // used to store tree structure
THREAD
public String toString() {
return "e_" + super.toString();
}
};
public enum ItemType {
ROOT, USER, FOLDER, BLOB, TAG, PROPERTY
public String toString() {
return "v_" + super.toString();
}
};
Best regards,
Artem Orobets
* Orient Technologiesthe Company behind OrientDB*
2014/1/20 Valentin Popov <[email protected]>
> ODB 1.5.1
>
> I think i found the problem, on graph init I do initialization of classes
> for Edges and Vertexes, and such classes has intersections like USER, so as
> I right understand it is not possible create classes with same name for
> Edges and Vertexes?
>
> public enum Relationship {
>
> USER, TAGS, PROPERTIES,
>
> FOLDERVERSION, ITEMVERSION, //used for versioned relations
>
> FOLDER, ITEM, // used to store tree structure
>
> THREAD
>
> };
>
>
> public enum ItemType {
>
> ROOT, USER, FOLDER, BLOB, TAG, PROPERTY
>
> };
>
>
>
> private void initGraph(){
>
> OGlobalConfiguration.CACHE_LEVEL1_ENABLED.setValue(false);
>
> OGlobalConfiguration.DB_USE_DISTRIBUTED_VERSION.setValue(false);
>
> OGlobalConfiguration.NON_TX_RECORD_UPDATE_SYNCH.setValue(true); //Executes
> a synch against the file-system at every record operation. This slows down
> records updates but guarantee reliability on unreliable drives
>
> OGlobalConfiguration.TX_LOG_SYNCH.setValue(true); //Executes a synch
> against the file-system for each log entry. This slows down transactions
> but guarantee transaction reliability on non-reliable drives
>
> graph = new OrientGraph(location);
>
> graph.getRawGraph().commit();
>
> for (ItemType type : ItemType.values()) {
>
> try {
>
> graph.createVertexType(type.toString().toLowerCase(Locale.ENGLISH
> )).setSuperClass(graph.getVertexBaseType());
>
> } catch (OSchemaException e) {
>
> logger.debug("Vertex class "+type.toString()+" already exists in current
> database", e);
>
> }
>
> };
>
> for (Relationship type : Relationship.values()) {
>
> try {
>
> graph.createEdgeType(type.toString().toLowerCase(Locale.ENGLISH
> )).setSuperClass(graph.getEdgeBaseType());
>
> } catch (OSchemaException e) {
>
> logger.debug("Edge class "+type.toString()+" already exists in current
> database", e);
>
> }
>
> };
>
> }
>
>
> понедельник, 20 января 2014 г., 14:43:30 UTC+4 пользователь Valentin Popov
> написал:
>
>> Hello everybody,
>>
>> Database was created on schema-less format, all vertices were inserted
>> with graph.addVertex(null), type of vertex is set on properties (like user,
>> email, etc..) right now we need convert all vertexes to schema-hybrid
>> format. Right now all vertexes converted to schema like
>>
>> public enum ItemType {
>>
>> ROOT, USER, FOLDER, BLOB, TAG, PROPERTY
>>
>> };
>>
>> for (ItemType type : ItemType.values()) {
>>
>> try {
>>
>> graph.createVertexType(type.toString());
>>
>> } catch (OSchemaException e) {
>>
>> logger.debug("Vertex class "+type.toString()+" already exists in current
>> database", e);
>>
>> }
>>
>> };
>>
>>
>> and all new vertexes inserted as graph.addVertex("class:"+
>> type.toString());
>>
>>
>> Problem is when I try associate items like graph.addEdge(null,
>> parentVertex, childVertex, relationship.toString().toLowerCase(Locale.
>> ENGLISH)); I get exception "The class user does not extend class 'E' and
>> therefore cannot be considered an Edge "
>>
>>
>> Thanks for any clue
>>
>>
>> Regards
>>
>> Valentin
>>
> --
>
> ---
> 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/groups/opt_out.
>
--
---
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/groups/opt_out.