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

org.umlg.qualifier.meta.DMeta Maven / Gradle / Ivy

There is a newer version: 1.2.5
Show newest version
package org.umlg.qualifier.meta;

import java.util.Iterator;

import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.umlg.runtime.adaptor.UMLG;
import org.umlg.runtime.adaptor.UmlgLabelConverterFactory;
import org.umlg.runtime.domain.BaseMetaNode;
import org.umlg.runtime.domain.UmlgMetaNode;

public class DMeta extends BaseMetaNode implements UmlgMetaNode {


	/**
	 * constructor for DMeta
	 * 
	 * @param vertex 
	 */
	public DMeta(Vertex vertex)  {
		this.vertex= vertex;
	}
	
	/**
	 * default constructor for DMeta
	 */
	public DMeta()  {
		this.vertex = UMLG.get().addVertex(this.getClass().getName());
		this.vertex.property("className", getClass().getName());
		defaultCreate();
		UMLG.get().getRoot().addEdge(getEdgeToRootLabel(), this.vertex);
	}

	@Override
	public void defaultCreate() {
		getUid();
	}
	
	public String getEdgeToRootLabel() {
		return UmlgLabelConverterFactory.getUmlgLabelConverter().convert("rootDMeta");
	}
	
	synchronized static public DMeta getInstance() {
		DMeta result;
		Iterator iter = UMLG.get().getRoot().edges(Direction.OUT, UmlgLabelConverterFactory.getUmlgLabelConverter().convert("rootDMeta"));
		if ( iter.hasNext() ) {
			result =  new DMeta(iter.next().inVertex());
		} else {
			iter = UMLG.get().getRoot().edges(Direction.OUT, UmlgLabelConverterFactory.getUmlgLabelConverter().convert("rootDMeta"));
			if ( !iter.hasNext() ) {
				result = new DMeta();
			} else {
				result = new DMeta(iter.next().inVertex());
			}
		}
		return result;
	}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy