use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class EvalPlugin method recalculate.
private void recalculate(final Engine engine, CalculateInfo info) {
if (info.getFormula() != null) {
Util utils = Util.getUtils(engine);
Element element = engine.getElement(info.getElementId());
Eval eval = utils.createAndFillEval(info, true);
try {
utils.fillResult(info.getAttributeId(), eval, element);
} catch (Exception e) {
utils.fillResult(info.getAttributeId(), e, element);
}
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class StandardAttributesPlugin method getOrderedTableElements.
public static List<Element> getOrderedTableElements(Engine engine, Attribute attribute, Element element) {
List<Element> elements = getTableElements(engine, attribute, element);
String path = getTablePath(element.getId(), attribute.getId());
byte[] bs = engine.getStream(path);
if (bs == null)
return elements;
List<Element> res = new ArrayList<Element>(elements.size());
try {
StringTokenizer st = new StringTokenizer(new String(bs, "UTF-8"));
while (st.hasMoreTokens()) {
String s = st.nextToken();
long id = Long.parseLong(s);
Element e = null;
for (Element element2 : elements) {
if (element2.getId() == id) {
e = element2;
break;
}
}
if (e != null) {
res.add(e);
elements.remove(e);
}
}
res.addAll(elements);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return res;
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class StandardAttributesPlugin method hasHistory.
public static boolean hasHistory(Engine engine, Element element, Attribute attribute) {
StandardAttributesPlugin plugin = getStandardPlugin(engine);
List<Element> elements = engine.findElements(plugin.historyQualifier.getId(), plugin.historyElement, element.getId());
for (Element element2 : elements) {
Long id = (Long) engine.getAttribute(element2, plugin.historyAttribute);
if (id.longValue() == attribute.getId())
return true;
}
return false;
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class StandardAttributesPlugin method getHistory.
public static List<Record> getHistory(Engine engine, Element element, Attribute attribute) {
StandardAttributesPlugin plugin = getStandardPlugin(engine);
List<Element> elements = engine.findElements(plugin.historyQualifier.getId(), plugin.historyElement, element.getId());
List<Record> res = new ArrayList<Record>();
for (Element element2 : elements) {
Long id = (Long) engine.getAttribute(element2, plugin.historyAttribute);
if (id.longValue() == attribute.getId()) {
Record record = new Record();
record.setDate((Date) engine.getAttribute(element2, plugin.historyTime));
record.setValue(engine.getAttribute(element2, attribute));
record.setElement(element2);
res.add(record);
}
}
Collections.sort(res);
return res;
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class OtherElementPlugin method replaceElements.
@Override
public void replaceElements(Engine engine, Element[] oldElements, Element newElement) {
for (Qualifier qualifier : getAllNotSystemQualifiers(engine)) {
List<Attribute> attributes = new ArrayList<Attribute>();
for (Attribute attribute : qualifier.getAttributes()) {
if ((attribute.getAttributeType().getPluginName().equals(getName())) && (attribute.getAttributeType().getTypeName().equals(getTypeName()))) {
OtherElementPropertyPersistent p = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
if (p.getQualifier() == newElement.getQualifierId())
attributes.add(attribute);
}
}
Hashtable<Element, Object[]> hash = engine.getElements(qualifier, attributes);
Enumeration<Element> keys = hash.keys();
while (keys.hasMoreElements()) {
Element key = keys.nextElement();
Object[] objects = hash.get(key);
int aIndex = 0;
for (Object object : objects) if (object != null) {
Long l = (Long) object;
for (Element element : oldElements) {
if (element.getId() == l.longValue()) {
engine.setAttribute(key, attributes.get(aIndex), newElement.getId());
break;
}
}
aIndex++;
}
}
}
}
Aggregations