Search in sources :

Example 6 with EntityAttribute

use of life.genny.qwanda.attribute.EntityAttribute in project rulesservice by genny-project.

the class QRules method getBaseEntityValueAsLocalDate.

public LocalDate getBaseEntityValueAsLocalDate(final String baseEntityCode, final String attributeCode) {
    BaseEntity be = getBaseEntityByCode(baseEntityCode);
    Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
    if (ea.isPresent()) {
        return ea.get().getValueDate();
    } else {
        return null;
    }
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 7 with EntityAttribute

use of life.genny.qwanda.attribute.EntityAttribute in project rulesservice by genny-project.

the class QRules method getMapOfAllAttributesValuesForBaseEntity.

/*
	 * Gets all the attribute and their value for the given basenentity code
	 */
public Map<String, String> getMapOfAllAttributesValuesForBaseEntity(String beCode) {
    BaseEntity be = getBaseEntityByCode(beCode);
    println("The load is ::" + be);
    Set<EntityAttribute> eaSet = be.getBaseEntityAttributes();
    println("The set of attributes are  :: " + eaSet);
    Map<String, String> attributeValueMap = new HashMap<String, String>();
    for (EntityAttribute ea : eaSet) {
        String attributeCode = ea.getAttributeCode();
        println("The attribute code  is  :: " + attributeCode);
        String value = ea.getAsLoopString();
        attributeValueMap.put(attributeCode, value);
    }
    return attributeValueMap;
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 8 with EntityAttribute

use of life.genny.qwanda.attribute.EntityAttribute in project rulesservice by genny-project.

the class QRules method getBaseEntityValueAsLocalTime.

public LocalTime getBaseEntityValueAsLocalTime(final String baseEntityCode, final String attributeCode) {
    BaseEntity be = getBaseEntityByCode(baseEntityCode);
    Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
    if (ea.isPresent()) {
        return ea.get().getValueTime();
    } else {
        return null;
    }
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 9 with EntityAttribute

use of life.genny.qwanda.attribute.EntityAttribute in project rulesservice by genny-project.

the class QRules method addAttributes.

public void addAttributes(BaseEntity be) {
    for (EntityAttribute ea : be.getBaseEntityAttributes()) {
        if (ea != null) {
            Attribute attribute = RulesUtils.attributeMap.get(ea.getAttributeCode());
            if (attribute != null) {
                ea.setAttribute(attribute);
            } else {
                RulesUtils.loadAllAttributesIntoCache(getToken());
                attribute = RulesUtils.attributeMap.get(ea.getAttributeCode());
                if (attribute != null) {
                    ea.setAttribute(attribute);
                } else {
                    log.error("Cannot get Attribute - " + ea.getAttributeCode());
                    Attribute dummy = new AttributeText(ea.getAttributeCode(), ea.getAttributeCode());
                    ea.setAttribute(dummy);
                }
            }
        }
    }
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) Attribute(life.genny.qwanda.attribute.Attribute) AttributeText(life.genny.qwanda.attribute.AttributeText)

Aggregations

EntityAttribute (life.genny.qwanda.attribute.EntityAttribute)9 BaseEntity (life.genny.qwanda.entity.BaseEntity)8 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Answer (life.genny.qwanda.Answer)2 QDataBaseEntityMessage (life.genny.qwanda.message.QDataBaseEntityMessage)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Attribute (life.genny.qwanda.attribute.Attribute)1 AttributeBoolean (life.genny.qwanda.attribute.AttributeBoolean)1 AttributeMoney (life.genny.qwanda.attribute.AttributeMoney)1 AttributeText (life.genny.qwanda.attribute.AttributeText)1 QEventAttributeValueChangeMessage (life.genny.qwanda.message.QEventAttributeValueChangeMessage)1 Money (org.javamoney.moneta.Money)1