use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.
the class NDataPlugin method createRow.
public Row createRow(final Row parent, boolean element, final GlobalId globalId) {
assert parent == null && !element || parent != null;
if (parent instanceof Stream) {
return (Row) streamsRowSet.createRow(baseStream);
}
if (parent instanceof Function)
throw new RuntimeException("Method can not be called to create functions!");
Row res;
if (!element) {
res = (Row) qualifiers.createRow((com.ramussoft.database.common.Row) parent);
} else {
com.ramussoft.database.common.Row row = qualifiers.findRow(((com.ramussoft.database.common.Row) parent).getElementId());
if (row != null) {
long qId = (Long) engine.getAttribute(row.getElement(), qualifierId);
RowSet rowSet = getRowSet(qId);
res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
} else {
RowSet rowSet = findRowSetByRowId(((com.ramussoft.database.common.Row) parent).getElementId());
res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
}
}
return res;
}
use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.
the class NDataPlugin method replaceParent.
private Row replaceParent(Row row, final boolean element) {
if ((!row.isElement()) && (element) && (!(row instanceof Stream)) && (!(row instanceof Function))) {
long id = (Long) ((com.ramussoft.database.common.Row) row).getAttribute(qualifierId);
RowSet rs = getRowSet(id);
row = (Row) rs.getRoot();
}
return row;
}
use of com.ramussoft.database.common.RowSet 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.RowSet in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method createDataPlugin.
private DataPlugin createDataPlugin() {
DataPlugin plugin = (DataPlugin) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { DataPlugin.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
String name = method.getName();
if ("getBaseFunction".equals(name)) {
if (rowBaseFunction == null) {
rowBaseFunction = getBaseFunction(dataPlugin, baseFunction);
}
return rowBaseFunction;
}
if ("getBaseFunctionQualifier".equals(name))
return baseFunction;
if ("isReadOnly".equals(name))
return !dataPlugin.getAccessRules().canUpdateQualifier(baseFunction.getId());
if ("createRow".equals(name)) {
com.ramussoft.pb.Row parent = (com.ramussoft.pb.Row) args[0];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent);
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ("createFunction".equals(name)) {
com.ramussoft.pb.Function parent = (com.ramussoft.pb.Function) args[0];
final Integer type = (Integer) args[1];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent, new ElementCreationCallback() {
@Override
public void created(Element element) {
Engine engine = dataPlugin.getEngine();
Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
engine.setAttribute(element, attribute, type);
}
});
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ((("getChilds".equals(name)) || ("getRecChilds".equals(name))) && (args[0] == null) && (((Boolean) args[1]) == false)) {
Vector v = (Vector) method.invoke(dataPlugin, args);
v.add(0, dataPlugin.getBaseStream());
v.add(0, getBaseFunction(dataPlugin, baseFunction));
return v;
}
if ("getProjectOptions".equals(name))
return getProjectOptions();
if ("setProjectOptions".equals(name))
return setProjectOptions((ProjectOptions) args[0]);
if ("refresh".equals(name)) {
fullRefrash((GUIFramework) args[0]);
return null;
}
return method.invoke(dataPlugin, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
private Row getBaseFunction(final NDataPlugin dataPlugin, final Qualifier baseFunction) {
return dataPlugin.getNBaseFunction(baseFunction.getId());
}
protected Object setProjectOptions(ProjectOptions projectOptions) {
getBaseFunction(dataPlugin, baseFunction).setAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()), projectOptions);
return null;
}
protected Object getProjectOptions() {
return getBaseFunction(dataPlugin, baseFunction).getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
}
});
plugin.getBaseFunction();
return plugin;
}
use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.
the class ElementListAttributeEditor method setValue.
@SuppressWarnings("unchecked")
@Override
public Object setValue(Object value) {
component.getModel().clearSelection();
List<ElementListPersistent> list = (List<ElementListPersistent>) value;
RowSet rowSet = component.getRowSet();
Row row = null;
for (ElementListPersistent p : list) {
long id = (left) ? p.getElement1Id() : p.getElement2Id();
row = rowSet.findRow(id);
if (row != null)
component.getModel().setSelectedRow(row, true);
}
if (row != null)
component.getTable().scrollRowToVisible(component.getTable().indexOfRow(row));
Collections.sort(list);
return value;
}
Aggregations