Search in sources :

Example 1 with Expression

use of org.whole.lang.queries.model.Expression in project whole by wholeplatform.

the class PojoUtils method getReadOnlyFields.

public static Set<Name> getReadOnlyFields(PojoDeclaration pojoDeclaration) {
    Set<Name> readOnlyFields = new HashSet<Name>();
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    Expression findAllReadOnlyFields = (Expression) PojoTemplateManager.instance().create("findAllReadOnlyFields");
    for (Name readOnlyField : BehaviorUtils.<Name>compileAndLazyEvaluate(findAllReadOnlyFields, pojoDeclaration, bindings)) readOnlyFields.add(readOnlyField);
    return readOnlyFields;
}
Also used : Expression(org.whole.lang.queries.model.Expression) PathExpression(org.whole.lang.queries.model.PathExpression) IBindingManager(org.whole.lang.bindings.IBindingManager) Name(org.whole.lang.pojo.model.Name) HashSet(java.util.HashSet)

Example 2 with Expression

use of org.whole.lang.queries.model.Expression in project whole by wholeplatform.

the class PojoUtils method findConstructor.

public static Constructor findConstructor(PojoDeclaration pojoDeclaration) {
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    Expression findParameterByTemplate = (Expression) PojoTemplateManager.instance().create("findParameterByTemplate");
    List<Constructor> constructors = getConstructors(pojoDeclaration);
    int[] supportedFields = new int[constructors.size()];
    Expression findAllReadOnlyFields = (Expression) PojoTemplateManager.instance().create("findAllReadOnlyFields");
    IEntityIterator<Name> iterator = BehaviorUtils.<Name>compileAndLazyEvaluate(findAllReadOnlyFields, pojoDeclaration, bindings);
    int readOnlyFieldCount = 0;
    while (iterator.hasNext()) {
        iterator.next();
        for (int i = 0; i < supportedFields.length; i++) if (BehaviorUtils.evaluateFirstResult(findParameterByTemplate, constructors.get(i), bindings) != null)
            supportedFields[i]++;
        readOnlyFieldCount++;
    }
    for (int i = 0; i < supportedFields.length; i++) if (supportedFields[i] >= readOnlyFieldCount)
        return constructors.get(i);
    return constructors.get(supportedFields.length - 1);
}
Also used : Expression(org.whole.lang.queries.model.Expression) PathExpression(org.whole.lang.queries.model.PathExpression) Constructor(org.whole.lang.pojo.model.Constructor) IBindingManager(org.whole.lang.bindings.IBindingManager) Name(org.whole.lang.pojo.model.Name)

Example 3 with Expression

use of org.whole.lang.queries.model.Expression in project whole by wholeplatform.

the class QueriesInterpreterVisitor method visit.

@Override
public void visit(FeatureStep entity) {
    IEntity self = getSelfEntity(entity);
    String featureName = entity.getValue();
    FeatureDescriptor fd = self.wGetLanguageKit().getFeatureDescriptorEnum().valueOf(featureName);
    if (fd == null || !self.wContains(fd))
        visit((Expression) entity);
    else
        setResult(self.wGet(fd));
}
Also used : IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) Expression(org.whole.lang.queries.model.Expression)

Example 4 with Expression

use of org.whole.lang.queries.model.Expression in project whole by wholeplatform.

the class ActionsUIContentAssistVisitor method createNotEqualsQuery.

protected IEntity createNotEqualsQuery(IEntity prototype) {
    Expression expression = createStageUpFragment(Expression, EntityUtils.clone(prototype));
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    return qef.createNot(qef.createExpressionTest(qef.createPointwiseEquals(qef.createSelfStep(), expression)));
}
Also used : Expression(org.whole.lang.queries.model.Expression) Expression(org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum.Expression) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory)

Example 5 with Expression

use of org.whole.lang.queries.model.Expression in project whole by wholeplatform.

the class PojoUtils method findProductDeclarationByTemplateName.

public static ProductDeclaration findProductDeclarationByTemplateName(EntityDescriptor<?> ed, Library library) {
    PojoEntityFactory pef = PojoEntityFactory.instance;
    Expression findProductDeclarationByTemplateName = (Expression) PojoTemplateManager.instance().create("findProductDeclarationByTemplateName");
    Name templateName = pef.createName(ed.getName());
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    bindings.wDef("templateName", templateName);
    return BehaviorUtils.evaluateFirstResult(findProductDeclarationByTemplateName, library, bindings);
}
Also used : PojoEntityFactory(org.whole.lang.pojo.factories.PojoEntityFactory) Expression(org.whole.lang.queries.model.Expression) PathExpression(org.whole.lang.queries.model.PathExpression) IBindingManager(org.whole.lang.bindings.IBindingManager) Name(org.whole.lang.pojo.model.Name)

Aggregations

Expression (org.whole.lang.queries.model.Expression)6 IBindingManager (org.whole.lang.bindings.IBindingManager)4 Name (org.whole.lang.pojo.model.Name)4 PathExpression (org.whole.lang.queries.model.PathExpression)4 IEntity (org.whole.lang.model.IEntity)2 Constructor (org.whole.lang.pojo.model.Constructor)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PojoEntityFactory (org.whole.lang.pojo.factories.PojoEntityFactory)1 ArrayType (org.whole.lang.pojo.model.ArrayType)1 CollectionType (org.whole.lang.pojo.model.CollectionType)1 MapType (org.whole.lang.pojo.model.MapType)1 Parameter (org.whole.lang.pojo.model.Parameter)1 PrimitiveType (org.whole.lang.pojo.model.PrimitiveType)1 Property (org.whole.lang.pojo.model.Property)1 ReferenceType (org.whole.lang.pojo.model.ReferenceType)1 Type (org.whole.lang.pojo.model.Type)1 PrimitiveType (org.whole.lang.pojo.reflect.PojoEntityDescriptorEnum.PrimitiveType)1 ReferenceType (org.whole.lang.pojo.reflect.PojoEntityDescriptorEnum.ReferenceType)1