Search in sources :

Example 1 with InstanceDecorator

use of eu.esdihumboldt.hale.common.instance.model.impl.InstanceDecorator in project hale by halestudio.

the class OrientInstanceReference method createReference.

/**
 * Create a reference for an instance
 *
 * @param instance the instance, which must be an {@link OInstance}
 * @return the instance reference
 * @throws IllegalArgumentException if the instance is no {@link OInstance}
 */
public static InstanceReference createReference(Instance instance) {
    if (instance.getDataSet() == null) {
        throw new IllegalArgumentException("Instance data set may not be null for retrieving reference");
    }
    while (instance instanceof InstanceDecorator) {
        instance = ((InstanceDecorator) instance).getOriginalInstance();
    }
    OInstance inst = (OInstance) instance;
    ORID id = inst.getDocument().getIdentity();
    return new OrientInstanceReference(id, instance.getDataSet(), inst.getDefinition());
}
Also used : InstanceDecorator(eu.esdihumboldt.hale.common.instance.model.impl.InstanceDecorator) OInstance(eu.esdihumboldt.hale.common.instance.orient.OInstance) ORID(com.orientechnologies.orient.core.id.ORID)

Aggregations

ORID (com.orientechnologies.orient.core.id.ORID)1 InstanceDecorator (eu.esdihumboldt.hale.common.instance.model.impl.InstanceDecorator)1 OInstance (eu.esdihumboldt.hale.common.instance.orient.OInstance)1