Search in sources :

Example 1 with TextPersistent

use of com.ramussoft.core.attribute.simple.TextPersistent in project ramus by Vitaliy-Yakovchuk.

the class AnyToAnyPlugin method getElementName.

private String getElementName(final IEngine engine, final HashMap<Long, Attribute> attributesCache, final HashMap<Long, Qualifier> qualifiersCache, ResultSet rs) throws SQLException {
    Element element = engine.getElement(rs.getLong("element_id"));
    if (element == null)
        return "";
    Qualifier qualifier;
    if (!qualifiersCache.containsKey(element.getQualifierId())) {
        qualifier = engine.getQualifier(element.getQualifierId());
        qualifiersCache.put(element.getQualifierId(), qualifier);
    } else
        qualifier = qualifiersCache.get(element.getQualifierId());
    if (qualifier == null || qualifier.getAttributeForName() < 0l)
        return "";
    Attribute attribute;
    if (!attributesCache.containsKey(qualifier.getAttributeForName())) {
        attribute = engine.getAttribute(qualifier.getAttributeForName());
        attributesCache.put(qualifier.getAttributeForName(), attribute);
    } else
        attribute = attributesCache.get(qualifier.getAttributeForName());
    if (attribute == null)
        return "";
    List<Persistent>[] bAttribute = engine.getBinaryAttribute(element.getId(), attribute.getId());
    if (bAttribute.length == 0)
        return "";
    List<Persistent> list = bAttribute[0];
    if (list.size() == 0)
        return "";
    if (list.get(0) instanceof TextPersistent)
        return String.valueOf(((TextPersistent) list.get(0)).getValue());
    else if (list.get(0) instanceof DFDSName)
        return String.valueOf(((DFDSName) list.get(0)).getShortName());
    return "";
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) ArrayList(java.util.ArrayList) List(java.util.List) TextPersistent(com.ramussoft.core.attribute.simple.TextPersistent) Persistent(com.ramussoft.common.persistent.Persistent) TextPersistent(com.ramussoft.core.attribute.simple.TextPersistent)

Aggregations

Attribute (com.ramussoft.common.Attribute)1 Element (com.ramussoft.common.Element)1 Qualifier (com.ramussoft.common.Qualifier)1 Persistent (com.ramussoft.common.persistent.Persistent)1 TextPersistent (com.ramussoft.core.attribute.simple.TextPersistent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1