use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class Util method fillMetaValues.
public void fillMetaValues(Eval eval, boolean toUserValue) {
String[] values = eval.getValues();
MetaValue[] mv = toMetaValues(values);
for (int i = 0; i < mv.length; i++) {
MetaValue metaValue = mv[i];
if (metaValue != null) {
Attribute attribute = engine.getAttribute(metaValue.getAttributeId());
Element element2 = engine.getElement(metaValue.getElementId());
eval.setValue(values[i], new EObject(engine.getAttribute(element2, attribute), element2, attribute, engine, toUserValue));
}
}
for (String functionName : eval.getFunctions()) {
eval.setFunction(functionName, new ScriptFunction(functionName));
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class Util method decompile.
public String decompile(Qualifier qualifier, String function) {
List<Attribute> attrs = qualifier.getAttributes();
final Hashtable<String, String> hash = new Hashtable<String, String>(attrs.size());
for (Attribute attr : attrs) {
if (attr.getAttributeType().toString().equals("Core.Table")) {
Qualifier table = engine.getSystemQualifier("TableQualifier_" + attr.getId());
for (Attribute tAttr : table.getAttributes()) {
hash.put(getAttributeEId(attr.getId(), tAttr.getId()), toCanonicalValue(attr.getName() + "." + tAttr.getName()));
}
}
hash.put(getAttributeEId(attr.getId()), toCanonicalValue(attr.getName()));
}
Eval eval = new Eval(function);
eval.replaceValueNames(new Replacementable() {
@Override
public String getNewName(String oldName) {
if ("ELEMENT".equals(oldName))
return oldName;
String name = hash.get(oldName);
if (name == null) {
if (oldName.startsWith(ELEMENT_PREFIX)) {
MetaValue metaValue = toMetaValue(oldName);
Element element = engine.getElement(metaValue.getElementId());
Attribute attribute = engine.getAttribute(metaValue.getAttributeId());
Qualifier qualifier = engine.getQualifier(element.getQualifierId());
return toCanonicalValue(qualifier.getName() + "." + element.getName() + "." + attribute.getName());
}
}
return name;
}
});
return eval.toString();
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class Util method decompileValue.
protected String decompileValue(final Element element, String oldName) {
MetaValue value = toMetaValue(oldName);
Attribute attribute = engine.getAttribute(value.getAttributeId());
if ((element != null) && (value.getElementId() == element.getId())) {
return toCanonicalValue(attribute.getName());
} else {
Element e = engine.getElement(value.getElementId());
if (e.getName().length() == 0)
return toCanonicalValue(ELEMENT_PREFIX + e.getId() + "." + attribute.getName());
if ((element != null) && (e.getQualifierId() == element.getQualifierId())) {
return toCanonicalValue(e.getName() + "." + attribute.getName());
} else {
Qualifier qualifier = engine.getQualifier(e.getQualifierId());
return toCanonicalValue(replaceDots(qualifier.getName()) + "." + replaceDots(e.getName()) + "." + replaceDots(attribute.getName()));
}
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class RowSet method createRow.
public Row createRow(Row parent, ElementCreationCallback callback) {
if (parent == null)
parent = root;
boolean started = isUserTransactionStarted();
try {
if (!started)
startUserTransaction();
Row row;
if (parent == null)
parent = root;
Element element = engine.createElement(qualifier.getId());
callback.created(element);
synchronized (this) {
row = rowHash.get(element.getId());
if (row == null)
row = createNativeRow(element);
row.setParent(parent);
}
for (RowChildListener listener : getRowChildListeners()) {
listener.addedByThisRowSet(row);
}
return row;
} finally {
if (!started)
commitUserTransaction();
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class RowSet method elementCreated.
protected void elementCreated(ElementEvent event) {
synchronized (this) {
Element element = event.getNewElement();
createNativeRow(element);
}
for (ElementListener l : getElementListeners()) {
l.elementCreated(event);
}
}
Aggregations