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);
}
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++;
}
}
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));
}
}
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);
}
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();
}
Aggregations