Search in sources :

Example 51 with Element

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));
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element)

Example 52 with Element

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();
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 53 with Element

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()));
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 54 with Element

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();
    }
}
Also used : Element(com.ramussoft.common.Element)

Example 55 with Element

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);
    }
}
Also used : Element(com.ramussoft.common.Element) ElementListener(com.ramussoft.common.event.ElementListener)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6