use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method openDiagram.
private void openDiagram(TreePath path) {
Object object = path.getLastPathComponent();
if (object instanceof ModelsNode) {
Qualifier qualifier = ((ModelsNode) object).getQualifier();
OpenDiagram open = new OpenDiagram(qualifier, -1l);
framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
} else {
Row row = (Row) object;
if (row.getChildCount() == 0)
row = row.getParent();
if (row instanceof ModelsNode) {
Qualifier qualifier = ((ModelsNode) row).getQualifier();
OpenDiagram open = new OpenDiagram(qualifier, -1l);
framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
} else {
if ((row != null) && (row.getElement() != null)) {
Qualifier qualifier = engine.getQualifier(row.getElement().getQualifierId());
OpenDiagram open = new OpenDiagram(qualifier, row.getElementId());
framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
}
}
}
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method getRecIDEF0Kod.
private static String getRecIDEF0Kod(final Row function) {
final Row f = function.getParent();
if (f == null || f.getParent() == null || (f.getParent().getParent() == null))
return "";
String id = Integer.toString(function.getId());
if (id.length() > 1)
id = "." + id + ".";
return getRecIDEF0Kod(f) + id;
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method checkModelTree.
private void checkModelTree(Qualifier modelTree) {
List<Qualifier> models = new ArrayList<Qualifier>();
List<Qualifier> qList = engine.getQualifiers();
for (Qualifier qualifier : qList) {
if (IDEF0Plugin.isFunction(qualifier)) {
models.add(qualifier);
}
}
Collections.sort(models, new Comparator<Qualifier>() {
@Override
public int compare(Qualifier o1, Qualifier o2) {
return StringCollator.compare(o1.getName(), o2.getName());
}
});
Attribute attribute = StandardAttributesPlugin.getAttributeQualifierId(engine);
RowSet rowSet = new RowSet(engine, modelTree, new Attribute[] { attribute }, null, true);
for (Row row : rowSet.getAllRows()) {
for (int i = models.size() - 1; i >= 0; --i) {
Qualifier model = models.get(i);
Long id = (Long) row.getAttribute(attribute);
if (id != null && model.getId() == id.longValue()) {
models.remove(i);
break;
}
}
}
for (Qualifier model : models) {
Row row = rowSet.createRow(null);
row.setName(model.getName());
row.setAttribute(attribute, model.getId());
}
}
use of com.ramussoft.database.common.Row 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.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class ModelPropertiesDialog method updateAttributesInOrder.
@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
List<Row> list = view.getSelectedRows();
List<Attribute> attributes = new ArrayList<Attribute>(list.size());
for (Row pr : list) {
Attribute attribute = StandardAttributesPlugin.getAttribute(engine, pr.getElement());
attributes.add(attribute);
if (qAttributes.indexOf(attribute) < 0)
qAttributes.add(attribute);
}
List<Attribute> rem = new ArrayList<Attribute>();
for (Attribute a : qAttributes) if (attributes.indexOf(a) < 0)
rem.add(a);
for (Attribute r : rem) qAttributes.remove(r);
}
Aggregations