use of com.ramussoft.common.CalculateInfo in project ramus by Vitaliy-Yakovchuk.
the class FormulaCommand method undo.
@Override
public void undo(IEngine engine) {
CalculateInfo oldInfo = this.oldInfo;
if (oldInfo == null) {
oldInfo = new CalculateInfo(newInfo.getElementId(), newInfo.getAttributeId(), null);
engine.setCalculateInfo(oldInfo);
} else
engine.setCalculateInfo(oldInfo);
FormulaEvent event = new FormulaEvent(this.engine, true, newInfo, oldInfo);
this.engine.formulaChanged(event);
}
use of com.ramussoft.common.CalculateInfo in project ramus by Vitaliy-Yakovchuk.
the class EvalPlugin method getElementsDeleteStatus.
@Override
public DeleteStatus getElementsDeleteStatus(long[] elementIds, IEngine engine) {
if (elementIds.length == 0)
return null;
Qualifier qualifier = engine.getQualifier(engine.getQualifierIdForElement(elementIds[0]));
StringBuffer sb = new StringBuffer();
List<MetaValue> list = new ArrayList<MetaValue>();
for (long elementId : elementIds) for (Attribute attr : qualifier.getAttributes()) {
for (CalculateInfo info : engine.getDependences(elementId, attr.getId(), false)) if (info.getElementId() != elementId) {
MetaValue value = new MetaValue(info.getElementId(), info.getAttributeId());
if (list.indexOf(value) < 0) {
list.add(value);
sb.append("<tr>");
Element element = engine.getElement(info.getElementId());
Qualifier qualifier2 = qualifier;
if (element.getQualifierId() != qualifier.getId()) {
qualifier2 = engine.getQualifier(element.getQualifierId());
}
Attribute attribute = engine.getAttribute(info.getAttributeId());
sb.append("<td>");
sb.append(qualifier2.getName());
sb.append("</td>");
sb.append("<td>");
sb.append(element.getName());
sb.append("</td>");
sb.append("<td>");
sb.append(attribute.getName());
sb.append("</td>");
sb.append("</tr>");
}
}
}
String string = sb.toString();
if (string.equals(""))
return null;
sb = new StringBuffer();
sb.append("{Eval.Function.Warning}");
sb.append("<br>");
sb.append("<table>");
sb.append("<tr><td><b>{OtherElement.Qualifier}</b></td><td><b>{AttributeType.Core.OtherElement}</b></td><td><b>{OtherElement.Attribute}</b></td></tr>");
sb.append(string);
sb.append("</table>");
DeleteStatus status = new DeleteStatus();
status.setDelete(Delete.WARNING);
status.setPluginName("Core");
status.setPluginAnswer(sb.toString());
return status;
}
use of com.ramussoft.common.CalculateInfo in project ramus by Vitaliy-Yakovchuk.
the class EvalPlugin method removeAttributeFromCalculateInfo.
private void removeAttributeFromCalculateInfo(final Engine engine, final Element element, final Attribute attribute) {
for (CalculateInfo info : engine.getDependences(element.getId(), attribute.getId(), false)) {
try {
Eval eval = new Eval(info.getFormula());
if (eval.replaceValueNames(new Replacementable() {
private String value = Util.ELEMENT_PREFIX + element.getId() + Util.ATTRIBUTE_PREFIX + attribute.getId();
@Override
public String getNewName(String oldName) {
if (oldName.equals(value))
return "NULL";
return null;
}
})) {
info.setFormula(eval.toString());
engine.setCalculateInfo(info);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations