Search in sources :

Example 66 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class Row method setNameObject.

public void setNameObject(Object name) {
    if (element == null) {
        return;
    }
    long id = rowSet.getQualifier().getAttributeForName();
    for (Attribute attr : attributes) {
        if (attr.getId() == id) {
            setAttribute(attr, name);
            return;
        }
    }
    Attribute attribute = engine.getAttribute(id);
    if (attribute != null)
        engine.setAttribute(element, attribute, name);
}
Also used : Attribute(com.ramussoft.common.Attribute)

Example 67 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class ComplexImport method importDromSheet.

public void importDromSheet(Sheet sheet, String sheetName, int startFrom, ImportRule[] rules) {
    this.sheetName = sheetName;
    Attribute name = rowSet.getEngine().getAttribute(rowSet.getQualifier().getAttributeForName());
    Row current = null;
    int row = startFrom;
    while (true) {
        org.apache.poi.ss.usermodel.Row row2 = sheet.getRow(row);
        if (row2 == null)
            break;
        for (ImportRule rule : rules) {
            if (rule.getAttribute().equals(name)) {
                String s = null;
                if (rule.getColumn() >= 0) {
                    Cell cell = row2.getCell(rule.getColumn());
                    if (cell != null) {
                        s = cell.getStringCellValue();
                    }
                } else
                    s = sheetName;
                if ((s != null) && (!"".equals(s))) {
                    Element element = null;
                    if (uniqueName)
                        element = rowSet.getEngine().getElement(s, rowSet.getQualifier().getId());
                    if (element != null)
                        current = null;
                    else {
                        current = rowSet.createRow(null);
                    }
                    for (ImportRule rule2 : rules) rule2.setObject(null);
                }
            }
        }
        Hashtable<Attribute, Element> tableElements = new Hashtable<Attribute, Element>(1);
        if (current != null)
            for (ImportRule rule : rules) {
                if (rule.getColumn() == -1) {
                    if (rule.getTableAttribute() == null) {
                        fill(current.getElement(), null, rule.getAttribute(), rule);
                    } else {
                        Element tableElement = tableElements.get(rule.getAttribute());
                        if (tableElement == null) {
                            tableElement = StandardAttributesPlugin.createTableElement(rowSet.getEngine(), rule.getAttribute(), current.getElement());
                            tableElements.put(rule.getAttribute(), tableElement);
                        }
                        fill(tableElement, null, rule.getTableAttribute(), rule);
                    }
                } else {
                    Cell cell = row2.getCell(rule.getColumn());
                    if (cell != null) {
                        if (rule.getTableAttribute() == null) {
                            fill(current.getElement(), cell, rule.getAttribute(), rule);
                        } else {
                            if (!isNull(cell)) {
                                Element tableElement = tableElements.get(rule.getAttribute());
                                if (tableElement == null) {
                                    tableElement = StandardAttributesPlugin.createTableElement(rowSet.getEngine(), rule.getAttribute(), current.getElement());
                                    tableElements.put(rule.getAttribute(), tableElement);
                                }
                                fill(tableElement, cell, rule.getTableAttribute(), rule);
                            }
                        }
                    }
                }
            }
        row++;
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Element(com.ramussoft.common.Element) Row(com.ramussoft.database.common.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 68 with Attribute

use of com.ramussoft.common.Attribute 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 69 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class Util method fillResult.

public void fillResult(long attributeId, Exception e, Element element) {
    Object object = null;
    e.printStackTrace();
    Attribute attribute = engine.getAttribute(attributeId);
    AttributeType attributeType = attribute.getAttributeType();
    if (attributeType.getPluginName().equals("Core")) {
        String typeName = attributeType.getTypeName();
        if (typeName.equals("Text")) {
            object = e.getLocalizedMessage();
        }
    }
    engine.setAttribute(element, attribute, object);
}
Also used : Attribute(com.ramussoft.common.Attribute) AttributeType(com.ramussoft.common.AttributeType)

Example 70 with Attribute

use of com.ramussoft.common.Attribute 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)

Aggregations

Attribute (com.ramussoft.common.Attribute)203 Qualifier (com.ramussoft.common.Qualifier)72 Element (com.ramussoft.common.Element)70 ArrayList (java.util.ArrayList)53 Engine (com.ramussoft.common.Engine)32 List (java.util.List)20 Row (com.ramussoft.database.common.Row)19 Hashtable (java.util.Hashtable)19 SQLException (java.sql.SQLException)16 AttributeType (com.ramussoft.common.AttributeType)15 FindObject (com.ramussoft.common.attribute.FindObject)11 AttributeEvent (com.ramussoft.common.event.AttributeEvent)11 ResultSet (java.sql.ResultSet)11 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)10 AccessRules (com.ramussoft.common.AccessRules)9 Transaction (com.ramussoft.common.persistent.Transaction)9 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)9 RowMapper (com.ramussoft.jdbc.RowMapper)9 Row (com.ramussoft.pb.Row)9 ImageIcon (javax.swing.ImageIcon)9