use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method createTemplateDataPlugin.
private static DataPlugin createTemplateDataPlugin() {
MemoryDatabase database = new MemoryDatabase() {
@Override
protected Collection<? extends PluginProvider> getAdditionalSuits() {
ArrayList<PluginProvider> ps = new ArrayList<PluginProvider>(1);
ps.add(new IDEF0PluginProvider());
return ps;
}
@Override
protected String getJournalDirectoryName(String tmp) {
return null;
}
@Override
protected FileIEngineImpl createFileIEngine(PluginFactory factory) throws ClassNotFoundException, ZipException, IOException {
return createNotSessionedFileIEngine(factory);
}
};
Engine e = database.getEngine(null);
AccessRules rules = database.getAccessRules(null);
Qualifier q = e.createQualifier();
IDEF0Plugin.installFunctionAttributes(q, e);
return getDataPlugin(q, e, rules);
}
use of com.ramussoft.common.Qualifier 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.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class SectorCorrector method run.
public void run(Engine engine, AccessRules accessRules) {
((Journaled) engine).startUserTransaction();
log("Loading data");
List<Qualifier> list = IDEF0Plugin.getBaseQualifiers(engine);
for (Qualifier q : list) {
DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(q, engine, accessRules);
Vector<Row> v = dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true);
for (Row r : v) {
if (r.getChildCount() == 0) {
Function function = (Function) r;
MovingArea area = new MovingArea(dataPlugin, function);
area.setDataPlugin(dataPlugin);
SectorRefactor sr = area.getRefactor();
sr.loadFromFunction(function, false);
while (sr.getSectorsCount() > 0) {
sr.getSector(0).remove();
}
sr.saveToFunction();
log("Function " + r + " clean");
}
}
for (Row r : v) {
if (r.getChildCount() != 0) {
Function function = (Function) r;
MovingArea area = new MovingArea(dataPlugin, function);
area.setDataPlugin(dataPlugin);
SectorRefactor sr = area.getRefactor();
sr.loadFromFunction(function, false);
for (int i = 0; i < sr.getSectorsCount(); i++) {
PaintSector ps = sr.getSector(i);
if ((ps.getSector().getStart().getFunction() != null) && (ps.getSector().getStart().getFunction().getChildCount() == 0))
sr.createSectorOnIn(ps, true);
if ((ps.getSector().getEnd().getFunction() != null) && (ps.getSector().getEnd().getFunction().getChildCount() == 0))
sr.createSectorOnIn(ps, false);
}
log("Function " + r + " done");
}
}
}
((Journaled) engine).commitUserTransaction();
}
use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class ModelParaleler method getQualifier.
@Override
public Qualifier getQualifier(long qualifierId) {
Qualifier q = qHash.get(qualifierId);
if (q != null)
return q;
Row row = rowForQualifiers.get(qualifierId);
if (row == null)
return null;
if (q == null) {
try {
q = StandardAttributesPlugin.getQualifier(toEngine, getRow(row).getElement());
qHash.put(qualifierId, q);
} catch (Exception e) {
e.printStackTrace();
}
}
return q;
}
use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class ModelParaleler method loadFromParalel.
public void loadFromParalel(Function base, boolean importAll, List<Qualifier> selected) {
this.base = base;
List<Attribute> tAttrs = toEngine.getAttributes();
List<Attribute> fAttrs = fromEngine.getAttributes();
for (Attribute f : fAttrs) for (Attribute t : tAttrs) if ((f.getName().equals(t.getName())) && (f.getAttributeType().equals(t.getAttributeType())))
attrHash.put(f.getId(), t);
List<Qualifier> fList = fromEngine.getQualifiers();
List<Qualifier> tList = toEngine.getQualifiers();
for (Qualifier f : fList) if (!IDEF0Plugin.isFunction(f))
for (Qualifier t : tList) if (!IDEF0Plugin.isFunction(t))
if (f.getName().equals(t.getName()))
qHash.put(f.getId(), t);
Vector<Row> fRows = fromDataPlugin.getRecChilds(null, false);
Vector<Row> tRows = toDataPlugin.getRecChilds(null, false);
for (Row f : fRows) {
for (Row t : tRows) {
if (f.getName().equals(t.getName())) {
rowHash.put(f.getElement().getId(), t);
Vector<Row> fCRows = fromDataPlugin.getRecChilds(f, true);
Vector<Row> tCRows = toDataPlugin.getRecChilds(t, true);
for (Row fc : fCRows) for (Row tc : tCRows) if (fc.getName().equals(tc.getName()))
rowHash.put(fc.getElement().getId(), tc);
}
}
}
if (importAll)
createAllRows();
for (Qualifier qualifier : selected) {
fromDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, fromEngine, fromDataPlugin.getAccessRules());
List<Attribute> list = getAttributes(qualifier.getAttributes());
Qualifier baseFunction = toEngine.getQualifier(base.getElement().getQualifierId());
for (Attribute a : list) if (baseFunction.getAttributes().indexOf(a) < 0)
baseFunction.getAttributes().add(a);
toEngine.updateQualifier(baseFunction);
int r;
if ((r = fromDataPlugin.getBaseFunction().getChildCount()) > 0)
for (int i = 0; i < r; i++) {
function = (Function) fromDataPlugin.getBaseFunction().getChildAt(i);
Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
childs.add(0, function);
for (Row row : childs) {
NFunction dest = (NFunction) getRow(row);
showMessageAnimation(dest.toString());
}
NFunction func = (NFunction) getRow(function);
createSectorsOnUpperLevel(func);
}
}
}
Aggregations