Search in sources :

Example 6 with RowSet

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;
}
Also used : Function(com.ramussoft.pb.Function) RowSet(com.ramussoft.database.common.RowSet) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row)

Example 7 with RowSet

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;
}
Also used : Function(com.ramussoft.pb.Function) RowSet(com.ramussoft.database.common.RowSet) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream)

Example 8 with RowSet

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());
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

Example 9 with RowSet

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;
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) ElementCreationCallback(com.ramussoft.database.common.ElementCreationCallback) Qualifier(com.ramussoft.common.Qualifier) Vector(java.util.Vector) Engine(com.ramussoft.common.Engine) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException) Row(com.ramussoft.database.common.Row) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 10 with RowSet

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;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) RowSet(com.ramussoft.database.common.RowSet) ArrayList(java.util.ArrayList) List(java.util.List) Row(com.ramussoft.database.common.Row)

Aggregations

RowSet (com.ramussoft.database.common.RowSet)18 Row (com.ramussoft.database.common.Row)9 Qualifier (com.ramussoft.common.Qualifier)8 Attribute (com.ramussoft.common.Attribute)7 Element (com.ramussoft.common.Element)5 ArrayList (java.util.ArrayList)5 Function (com.ramussoft.pb.Function)3 JScrollPane (javax.swing.JScrollPane)3 Engine (com.ramussoft.common.Engine)2 Row (com.ramussoft.pb.Row)2 Stream (com.ramussoft.pb.Stream)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 JList (javax.swing.JList)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)2 ListSelectionListener (javax.swing.event.ListSelectionListener)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 ProjectOptions (com.dsoft.pb.idef.elements.ProjectOptions)1 IEngine (com.ramussoft.common.IEngine)1 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)1