All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.runtime.domain.BaseMetaNode Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.umlg.runtime.domain;


import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;

import java.util.UUID;

/**
 * Date: 2013/03/09
 * Time: 8:42 AM
 */
public abstract class BaseMetaNode implements UmlgMetaNode {
    protected Vertex vertex;

    public BaseMetaNode() {
        super();
    }

    @Override
    public Vertex getVertex() {
        return vertex;
    }

    @Override
    public final Object getId() {
        return this.vertex.id();
    }

    @Override
    public String getUid() {
        Property uidProperty = this.vertex.property("uid");
        if ( !uidProperty.isPresent() || (uidProperty.value() == null) || uidProperty.value().trim().length()==0 ) {
            String uid = UUID.randomUUID().toString();
            this.vertex.property("uid", uid);
            return uid;
        } else {
            return uidProperty.value();
        }
    }

    public void defaultCreate() {
        getUid();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy