Search in sources :

Example 1 with SemanticsEntityFactory

use of org.whole.lang.semantics.factories.SemanticsEntityFactory in project whole by wholeplatform.

the class SemanticsUtils method createTerm.

public static IEntity createTerm(String edUri, FreshNameGenerator nameGenerator) {
    EntityDescriptor<?> ed = CommonsDataTypePersistenceParser.getEntityDescriptor(edUri, false, null);
    if (ed == null || (!EntityUtils.isSimple(ed) && !EntityUtils.isFragment(ed)))
        return SemanticsEntityFactory.instance.createEntityType(edUri);
    int size = ed.featureSize();
    IEntity[] values = new IEntity[size];
    SemanticsEntityFactory sf = SemanticsEntityFactory.instance;
    for (int i = 0; i < size; i++) {
        FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
        values[i] = sf.buildTypedVariable().set(SemanticsFeatureDescriptorEnum.variable, sf.createVariable(nameGenerator.nextFreshName(fd.getName()))).set(SemanticsFeatureDescriptorEnum.signature, sf.createEntityType(fd.getEntityDescriptor().toString())).getResult();
    }
    return CommonsEntityFactory.instance.createStageUpFragment(GenericEntityFactory.instance.create(ed, values).wGetAdapter(CommonsEntityDescriptorEnum.Any));
}
Also used : IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) SemanticsEntityFactory(org.whole.lang.semantics.factories.SemanticsEntityFactory)

Aggregations

IEntity (org.whole.lang.model.IEntity)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 SemanticsEntityFactory (org.whole.lang.semantics.factories.SemanticsEntityFactory)1