Search in sources :

Example 1 with RowSet

use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.

the class ReportQueryImpl method getHTMLReports.

@Override
public List<Element> getHTMLReports() {
    RowSet rowSet = new RowSet(engine, ReportPlugin.getReportsQualifier(engine), new Attribute[] {}, null, true);
    List<Row> rows = rowSet.getAllRows();
    List<Element> elements = new ArrayList<Element>(rows.size());
    for (Row row : rows) elements.add(row.getElement());
    return elements;
}
Also used : Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

Example 2 with RowSet

use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.

the class RSFViewer2 method createQualifiersList.

private Component createQualifiersList() {
    // Load tree with elements meta data standard system qualifier.
    RowSet rowSet = new RowSet(engine, StandardAttributesPlugin.getQualifiersQualifier(engine), new Attribute[] {});
    final JTree qualifiersTree = new JTree(new DefaultTreeModel(rowSet.getRoot()));
    qualifiersTree.setRootVisible(false);
    qualifiersTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        RowSet rowSet = null;

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            // Load elements of qualifier.
            // We will load elements with RowSet class,
            // you can also load elements with engne.getElements
            // methods.
            Object value = qualifiersTree.getSelectionPath().getLastPathComponent();
            // Value is really a Row element.
            if (value != null) {
                if (rowSet != null) {
                    // If rowSet is opened, we
                    // should close it and free
                    // all listeners.
                    rowSet.close();
                    // Just in case :)
                    rowSet = null;
                }
                Row qualifierRow = (Row) value;
                // Even you are not going to use any attribute,
                // use RowSet(Engine, Qualifier Attribute[])
                // constructor
                // instead of RowSet(Engine, Qualifier) constructor.
                rowSet = new RowSet(engine, StandardAttributesPlugin.getQualifier(engine, qualifierRow.getElement()), new Attribute[] {});
                // And just load tree component with elements
                // covered to Row objects.
                tree.setModel(new DefaultTreeModel(rowSet.getRoot()));
            }
        }
    });
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(qualifiersTree);
    return pane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) RowSet(com.ramussoft.database.common.RowSet) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) Row(com.ramussoft.database.common.Row)

Example 3 with RowSet

use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.

the class QualifierImporterImpl method createQualifier.

private Qualifier createQualifier(Qualifier sourceQualifier, Row row) {
    Qualifier res = engine.getQualifierByName(sourceQualifier.getName());
    if (res == null) {
        Qualifier q = StandardAttributesPlugin.getQualifiersQualifier(engine);
        RowSet rs = new RowSet(engine, q, new Attribute[] {});
        Row parent = findParent(rs, row.getParent());
        if ((parent != null) && (parent.getElement() == null))
            parent = null;
        if ((parent != null) && (engine.getElements(StandardAttributesPlugin.getQualifier(engine, parent.getElement()).getId()).size() > 0))
            parent = null;
        Element element = rs.createRow(parent).getElement();
        res = StandardAttributesPlugin.getQualifier(engine, element);
        res.setName(sourceQualifier.getName());
        engine.updateQualifier(res);
        rs.close();
    }
    return res;
}
Also used : Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

Example 4 with RowSet

use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.

the class NDataPlugin method clear.

@Override
public synchronized void clear() {
    for (RowSet rs : rowSets.values()) rs.close();
    rowSets.clear();
    sectorsRowSet.clear();
    loadSectors();
    crosspoints.clear();
    qualifiers.refresh();
}
Also used : RowSet(com.ramussoft.database.common.RowSet)

Example 5 with RowSet

use of com.ramussoft.database.common.RowSet in project ramus by Vitaliy-Yakovchuk.

the class NDataPlugin method getRowSet.

public RowSet getRowSet(final long id) {
    RowSet res = rowSets.get(id);
    if (res == null) {
        final Qualifier qualifier = engine.getQualifier(id);
        boolean create = true;
        if (IDEF0Plugin.isFunction(qualifier)) {
            create = false;
            List<Attribute> list = new ArrayList<Attribute>(qualifier.getSystemAttributes());
            list.addAll(qualifier.getAttributes());
            final Qualifier baseFunctions = IDEF0Plugin.getBaseFunctions(engine);
            res = new RowSet(engine, qualifier, list.toArray(new Attribute[list.size()]), new RowSet.RowCreater() {

                @Override
                public com.ramussoft.database.common.Row createRow(Element element, RowSet data, Attribute[] attributes, Object[] objects) {
                    if (element != null)
                        return new NFunction(NDataPlugin.this, element, data, attributes, objects) {

                            @Override
                            public long getQualifierId() {
                                if (id == baseFunctions.getId()) {
                                    return IDEF0Plugin.getBaseQualifierId(engine, getElement());
                                }
                                return id;
                            }
                        };
                    return new NFunction(NDataPlugin.this, IDEF0Plugin.findElementForBaseFunction(id, engine), data, attributes, objects) {

                        @Override
                        public String getName() {
                            return qualifier.getName();
                        }

                        @Override
                        public boolean isBase() {
                            return true;
                        }

                        @Override
                        public boolean isElement() {
                            return false;
                        }

                        @Override
                        public long getQualifierId() {
                            return id;
                        }
                    };
                }
            }) {

                @Override
                protected boolean filter(Element element) {
                    return false;
                }
            };
        }
        if (create)
            res = new RowSet(engine, qualifier, qualifier.getAttributes().toArray(new Attribute[qualifier.getAttributes().size()]), new RowSet.RowCreater() {

                @Override
                public com.ramussoft.database.common.Row createRow(Element element, RowSet data, Attribute[] attributes, Object[] objects) {
                    NRow row = new NRow(NDataPlugin.this, element, data, attributes, objects);
                    row.setElement(true);
                    return row;
                }
            });
        rowSets.put(id, res);
    }
    return res;
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.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