use of com.ramussoft.common.attribute.AttributeConverter in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method findElements.
@Override
public List<Element> findElements(long qualifierId, Attribute attribute, Object object) {
AttributeConverter converter = pluginFactory.getAttributeConverter(attribute.getAttributeType());
FindObject[] findObjects = converter.getFindObjects(object);
if (findObjects != null)
return deligate.getElements(qualifierId, attribute, findObjects);
List<Attribute> list = new ArrayList<Attribute>(1);
list.add(attribute);
Hashtable<Element, Object[]> elements = getElements(getQualifier(qualifierId), list);
ArrayList<Element> res = new ArrayList<Element>();
Enumeration<Element> e = elements.keys();
while (e.hasMoreElements()) {
Element element = e.nextElement();
if (objectEquals(object, elements.get(element)[0])) {
res.add(element);
}
}
Collections.sort(res, new Comparator<Element>() {
@Override
public int compare(Element o1, Element o2) {
if (o1.getId() < o2.getId())
return -1;
if (o1.getId() > o2.getId())
return 1;
return 0;
}
});
return res;
}
use of com.ramussoft.common.attribute.AttributeConverter in project ramus by Vitaliy-Yakovchuk.
the class AbstractJournaledEngine method setAttribute.
@Override
public void setAttribute(Element element, Attribute attribute, Object object) {
if (element != null)
if (missAttributes.get(attribute.getId()) == null) {
missAttributes.put(attribute.getId(), Boolean.TRUE);
} else
return;
try {
AttributeConverter converter = pluginFactory.getAttributeConverter(attribute.getAttributeType());
Object old = getAttribute(element, attribute);
setPersistentAttribute(element, attribute, object, converter);
String typeName = attribute.getAttributeType().toString();
if (element != null && (typeName.equals("Core.Text") || typeName.equals("IDEF0.DFDSName"))) {
Qualifier q = getQualifier(element.getQualifierId());
if (q.getAttributeForName() == attribute.getId()) {
if (object == null)
element.setName("");
else
element.setName(object.toString());
}
}
AttributeEvent event = new AttributeEvent(this, element, attribute, old, object);
attributeChanged(event);
} catch (Exception e) {
}
if (element != null)
missAttributes.remove(attribute.getId());
}
Aggregations