use of com.ramussoft.common.Element 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.Element in project ramus by Vitaliy-Yakovchuk.
the class DeleteElementCommand method undo.
@Override
public void undo(IEngine iEngine) {
Qualifier qualifier = iEngine.getQualifier(qualifierId);
Element element = iEngine.createElement(qualifierId, elementId);
ElementEvent event = new ElementEvent(engine, null, element, qualifierId, true);
engine.elementCreated(event);
List<Attribute> attrs = qualifier.getAttributes();
attrs.addAll(qualifier.getSystemAttributes());
int i = 0;
for (Attribute attr : attrs) {
iEngine.setBinaryAttribute(elementId, attr.getId(), data[i]);
Object object = engine.getAttribute(element, attr);
if ((attr.getId() == qualifier.getAttributeForName()) && (object != null)) {
element.setName(object.toString());
}
AttributeEvent event2 = new AttributeEvent(engine, element, attr, null, object, true);
engine.attributeChanged(event2);
i++;
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class UpdateQualifierCommand method undo.
@Override
public void undo(IEngine iEngine) {
iEngine.updateQualifier(oldQualifier);
QualifierEvent event = new QualifierEvent(engine, newQualifier, oldQualifier, true);
for (Attribute attribute : deletedAttributes) {
for (Entry<Long, Transaction> entry : hashtable.get(attribute.getId()).entrySet()) {
iEngine.setBinaryAttribute(entry.getKey(), attribute.getId(), entry.getValue());
Element element = iEngine.getElement(entry.getKey());
AttributeEvent event2 = new AttributeEvent(engine, element, attribute, null, engine.getAttribute(element, attribute), true);
engine.attributeChanged(event2);
}
}
if (oldQualifier.getAttributeForName() != newQualifier.getAttributeForName())
getEngine().updateElementNames(newQualifier, oldQualifier);
engine.qualifierUpdated(event);
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class CreateElementCommand method undo.
@Override
public void undo(IEngine iEngine) {
Element element = iEngine.getElement(elementId);
ElementEvent event = new ElementEvent(engine, element, null, qualifierId, true);
engine.beforeElementDeleted(event);
iEngine.deleteElement(elementId);
engine.elementDeleted(event);
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class SetElementQualifierCommand method redo.
@Override
public void redo(IEngine iEngine) {
Element old = iEngine.getElement(elementId);
Element newElement = new Element(old.getId(), newQualifierId, old.getName());
ElementEvent event = new ElementEvent(engine, old, newElement, oldQualifierId, true);
engine.beforeElementDeleted(event);
iEngine.setElementQualifier(elementId, newQualifierId);
engine.removeElementQualifierFromBuffer(elementId);
engine.elementDeleted(event);
engine.elementCreated(event);
}
Aggregations