Search in sources :

Example 41 with Qualifier

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

the class HTTPParser method printReport.

private void printReport(final String string) throws IOException {
    final long num = Long.parseLong(string);
    Element report = null;
    report = dataPlugin.getEngine().getElement(num);
    if (report == null) {
        printError(RES.getString("reportEror"));
        return;
    }
    htmlTitle = report.getName();
    printStartD();
    Query query = null;
    Qualifier qualifier = ((ReportQuery) dataPlugin.getEngine()).getHTMLReportQuery(report);
    if (qualifier != null) {
        query = new Query(null);
        List<Element> elements = new ArrayList<Element>();
        for (Row row : getSelRows(qualifier)) {
            elements.add(row.getElement());
        }
        query.setElements(elements);
    }
    printReport(report, query);
    printEndD();
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Query(com.ramussoft.report.Query) ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow)

Example 42 with Qualifier

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

the class HTTPParser method printRowAttributes.

private void printRowAttributes(final Row row) throws IOException {
    Element element = row.getElement();
    Qualifier qualifier = dataPlugin.getEngine().getQualifier(element.getQualifierId());
    List<Attribute> attributes = qualifier.getAttributes();
    for (Attribute attr : attributes) {
        if (attr.getId() != qualifier.getAttributeForName()) {
            factory.printAttribute(htmlStream, dataPlugin, element, this, attr);
        }
    }
    IEngine deligate = dataPlugin.getEngine().getDeligate();
    if (deligate instanceof IEngineImpl) {
        final IEngineImpl impl = (IEngineImpl) deligate;
        String prefix = impl.getPrefix();
        JDBCTemplate template = impl.getTemplate();
        List<OtherElementMetadata> list = template.query("SELECT * FROM " + prefix + "attribute_other_elements a WHERE other_element=? AND value_branch_id IN (SELECT branch_id FROM " + prefix + "attributes_data_metadata WHERE attribute_id=a.attribute_id AND element_id=a.element_id)", new RowMapper() {

            private Hashtable<Long, Attribute> attrs = new Hashtable<Long, Attribute>();

            private Hashtable<Long, Qualifier> qualifiers = new Hashtable<Long, Qualifier>();

            @Override
            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                OtherElementMetadata metadata = new OtherElementMetadata();
                Element element = impl.getElement(rs.getLong("element_id"));
                if (element == null)
                    return null;
                metadata.element = element;
                metadata.qualifier = getQualifier(element.getQualifierId());
                metadata.attribute = getAttribute(rs.getLong("attribute_id"));
                return metadata;
            }

            private Attribute getAttribute(Long id) {
                Attribute attribute = attrs.get(id);
                if (attribute == null) {
                    attribute = dataPlugin.getEngine().getAttribute(id);
                    attrs.put(id, attribute);
                }
                return attribute;
            }

            private Qualifier getQualifier(Long id) {
                Qualifier qualifier = qualifiers.get(id);
                if (qualifier == null) {
                    qualifier = dataPlugin.getEngine().getQualifier(id);
                    qualifiers.put(id, qualifier);
                }
                return qualifier;
            }
        }, new Object[] { row.getElement().getId() }, true);
        boolean print = false;
        for (OtherElementMetadata data : list) if (data.isNotSystem()) {
            print = true;
            break;
        }
        if (print) {
            Collections.sort(list);
            htmlStream.println("<table border=1>");
            htmlStream.println("<tr>");
            htmlStream.print("<td><b>");
            htmlStream.print(RES.getString("clasificator"));
            htmlStream.print("</b></td>");
            htmlStream.print("<td><b>");
            htmlStream.print(RES.getString("rowAttribute"));
            htmlStream.print("</b></td>");
            htmlStream.print("<td><b>");
            htmlStream.print(RES.getString("element"));
            htmlStream.print("</b></td>");
            htmlStream.println("</tr>");
            Hashtable<Qualifier, Element> hash = new Hashtable<Qualifier, Element>();
            for (OtherElementMetadata data : list) if (data.isNotSystem()) {
                Element element2 = hash.get(data.qualifier);
                if (element2 == null) {
                    element2 = StandardAttributesPlugin.getElement(dataPlugin.getEngine(), data.qualifier.getId());
                    hash.put(data.qualifier, element2);
                }
                htmlStream.println("<tr>");
                htmlStream.print("<td>");
                printStartATeg("rows/index.html?id=" + element2.getId());
                htmlStream.print(data.qualifier.getName());
                printEndATeg();
                htmlStream.print("</td>");
                htmlStream.print("<td>");
                htmlStream.print(data.attribute.getName());
                htmlStream.print("</td>");
                htmlStream.print("<td>");
                printStartATeg("rows/index.html?id=" + data.element.getId());
                htmlStream.print(data.element.getName());
                printEndATeg();
                htmlStream.print("</td>");
                htmlStream.println("</tr>");
            }
            htmlStream.println("</table><br>");
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) SQLException(java.sql.SQLException) Hashtable(java.util.Hashtable) Element(com.ramussoft.common.Element) IEngine(com.ramussoft.common.IEngine) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) JDBCTemplate(com.ramussoft.jdbc.JDBCTemplate) ResultSet(java.sql.ResultSet) Qualifier(com.ramussoft.common.Qualifier) RowMapper(com.ramussoft.jdbc.RowMapper)

Example 43 with Qualifier

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

the class TableAttributeViewer method printAttribute.

@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
    Engine engine = dataPlugin.getEngine();
    List<Element> list = StandardAttributesPlugin.getTableElements(engine, attribute, element);
    Qualifier qualifier = StandardAttributesPlugin.getTableQualifierForAttribute(engine, attribute);
    if (list.size() > 0) {
        callback.beforePrint(printStream);
        printStream.println("<br>");
        printStream.println("<table border=1><tr>");
        List<Attribute> add = new ArrayList<Attribute>();
        List<TableGroupablePropertyPersistent> l = (List) engine.getAttribute(null, attribute);
        for (Attribute attr : qualifier.getAttributes()) if (add.indexOf(attr) < 0) {
            String name = attr.getName();
            int colspan = 1;
            int rowspan = 2;
            for (TableGroupablePropertyPersistent p : l) {
                if ((p.getOtherAttribute() == attr.getId()) && (p.getName() != null) && (p.getName().length() > 0)) {
                    name = p.getName();
                    rowspan = 1;
                    colspan = 0;
                    for (Attribute a1 : qualifier.getAttributes()) for (TableGroupablePropertyPersistent p1 : l) {
                        if ((name.equals(p1.getName())) && (p1.getOtherAttribute() == a1.getId())) {
                            colspan++;
                            add.add(a1);
                        }
                    }
                }
            }
            printStream.print("<td align=\"center\" rowspan=\"" + rowspan + "\" colspan=\"" + colspan + "\"><b>" + name + "</b></td>");
        }
        printStream.println("</tr>");
        printStream.println("<tr>");
        for (Attribute a : add) {
            printStream.print("<td align=\"center\"><b>" + a.getName() + "</b></td>");
        }
        printStream.println("</tr>");
        AttributeViewerFactory factory = AttributeViewerFactory.getAttributeViewverFactory();
        for (Element element2 : list) {
            printStream.println("<tr>");
            for (Attribute attribute2 : qualifier.getAttributes()) {
                printStream.print("<td>");
                AttributeViewer viewer = factory.getAttributeViewer(attribute2);
                if (viewer != null) {
                    EmptyAttributeViewerCallback callback2 = new EmptyAttributeViewerCallback();
                    viewer.printAttribute(printStream, dataPlugin, element2, attribute2, parser, callback2);
                    if (!callback2.isBefore())
                        printStream.print("<center>-</center>");
                } else
                    printStream.print("<center>-</center>");
                printStream.println("</td>");
            }
            printStream.println("</tr>");
        }
        printStream.println("</table>");
        callback.afterPrint(printStream);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) AttributeViewer(com.ramussoft.pb.print.AttributeViewer) Qualifier(com.ramussoft.common.Qualifier) ArrayList(java.util.ArrayList) List(java.util.List) TableGroupablePropertyPersistent(com.ramussoft.core.attribute.simple.TableGroupablePropertyPersistent) Engine(com.ramussoft.common.Engine)

Example 44 with Qualifier

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

the class IDEF0Plugin method init.

@Override
public void init(final Engine engine, AccessRules accessor) {
    super.init(engine, accessor);
    engine.setPluginProperty(IDEF0, PLUGIN, this);
    Qualifier crosspoints = getQualifier(CROSSPOINTS);
    if (crosspoints != null) {
        List<Element> elements = engine.getElements(crosspoints.getId());
        Attribute crosspointId = getSysteAttribute(CROSSPOINT_ID_ATTRIBUTE);
        if (elements.size() > 0) {
            Element element = elements.get(0);
            try {
                long long1 = (Long) engine.getAttribute(element, crosspointId);
                while ((long1 > engine.nextValue(CROSSPOINTS_SEQUENCE))) ;
            } catch (NullPointerException e) {
            }
            engine.deleteElement(element.getId());
        }
        crosspoints.getSystemAttributes().clear();
        engine.updateQualifier(crosspoints);
        try {
            engine.deleteAttribute(crosspointId.getId());
        } catch (Exception e) {
        }
        engine.deleteQualifier(crosspoints.getId());
    }
    functionAttributes.add(createAttribute(F_VISUAL_DATA, new AttributeType(IDEF0, "VisualData", false)));
    functionAttributes.add(createAttribute(F_PAGE_SIZE, new AttributeType("Core", "Text", true)));
    functionAttributes.add(createAttribute(F_BACKGROUND, new AttributeType(IDEF0, "Color", false)));
    functionAttributes.add(createAttribute(F_FOREGROUND, new AttributeType(IDEF0, "Color", false)));
    functionAttributes.add(createAttribute(F_BOUNDS, new AttributeType(IDEF0, "FRectangle", false)));
    functionAttributes.add(createAttribute(F_FONT, new AttributeType(IDEF0, "Font", false)));
    functionAttributes.add(createAttribute(F_STATUS, new AttributeType(IDEF0, "Status", false)));
    functionAttributes.add(createAttribute(F_TYPE, new AttributeType(IDEF0, "Type", false)));
    functionAttributes.add(createAttribute(F_OUNER_ID, new AttributeType(IDEF0, "OunerId", false)));
    functionAttributes.add(createAttribute(F_DECOMPOSITION_TYPE, new AttributeType(IDEF0, "DecompositionType", false)));
    functionAttributes.add(createAttribute(F_AUTHOR, new AttributeType("Core", "Text", true)));
    functionAttributes.add(createAttribute(F_CREATE_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_REV_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_SYSTEM_REV_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_LINK, new AttributeType("Core", "Long", false)));
    Attribute sectorFunction = createAttribute(F_SECTOR_FUNCTION, new AttributeType("Core", "OtherElement", false));
    Attribute sStream = createAttribute(F_SECTOR_STREAM, new AttributeType("Core", "OtherElement", false));
    Attribute sPoints = createAttribute(F_SECTOR_POINTS, new AttributeType(IDEF0, "SectorPoint", false));
    Attribute sProperties = createAttribute(F_SECTOR_PROPERTIES, new AttributeType(IDEF0, "SectorProperties", false));
    Attribute sStreamName = createAttribute(F_STREAM_NAME, new AttributeType("Core", "Text", true));
    Attribute aSector = createAttribute(F_SECTOR_ATTRIBUTE, new AttributeType(IDEF0, "Sector", false));
    Attribute aSectorBorderStart = createAttribute(F_SECTOR_BORDER_START, new AttributeType(IDEF0, "SectorBorder", false));
    Attribute aSectorBorderEnd = createAttribute(F_SECTOR_BORDER_END, new AttributeType(IDEF0, "SectorBorder", false));
    Attribute aStreamAdded = createAttribute(F_STREAM_ADDED, new AttributeType(IDEF0, "AnyToAny", false));
    baseFunctionQualifierId = createAttribute(F_BASE_FUNCTION_QUALIFIER_ID, new AttributeType("Core", "Long", true));
    visualAttributes.add(getAttribute(engine, F_BOUNDS));
    visualAttributes.add(getAttribute(engine, F_FONT));
    visualAttributes.add(getAttribute(engine, F_BACKGROUND));
    visualAttributes.add(getAttribute(engine, F_FOREGROUND));
    Qualifier sectors = createQualifier(F_SECTORS);
    if (justCreated) {
        sectors.getSystemAttributes().add(aSector);
        sectors.getSystemAttributes().add(aSectorBorderStart);
        sectors.getSystemAttributes().add(aSectorBorderEnd);
        sectors.getSystemAttributes().add(sectorFunction);
    }
    Qualifier streams = createQualifier(F_STREAMS);
    boolean updateSectors = false;
    if (justCreated) {
        Attribute hierarchical = (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE);
        OtherElementPropertyPersistent p = new OtherElementPropertyPersistent();
        p.setQualifier(sectors.getId());
        p.setQualifierAttribute(sStreamName.getId());
        engine.setAttribute(null, sStream, p);
        streams.getSystemAttributes().add(aStreamAdded);
        streams.getSystemAttributes().add(hierarchical);
        streams.getSystemAttributes().add(sStreamName);
        streams.setAttributeForName(sStreamName.getId());
        engine.updateQualifier(streams);
        sectors.getSystemAttributes().add(0, sStream);
        sectors.getSystemAttributes().add(hierarchical);
        updateSectors = true;
    }
    if (sectors.getSystemAttributes().indexOf(sStream) != 0) {
        sectors.getSystemAttributes().remove(sStream);
        sectors.getSystemAttributes().add(0, sStream);
        updateSectors = true;
    }
    if (sectors.getSystemAttributes().indexOf(sPoints) < 0) {
        sectors.getSystemAttributes().add(sPoints);
        sectors.getSystemAttributes().add(sProperties);
        updateSectors = true;
    }
    if (updateSectors)
        engine.updateQualifier(sectors);
    projectPreferencesAttrtibute = createAttribute(F_PROJECT_PREFERENCES, new AttributeType(IDEF0, "ProjectPreferences", false));
    baseFunctions = createQualifier(F_BASE_FUNCTIONS);
    if (justCreated) {
        baseFunctions.getSystemAttributes().add(baseFunctionQualifierId);
        baseFunctions.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
        baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
        engine.updateQualifier(baseFunctions);
        installFunctionAttributes(baseFunctions, engine);
    } else {
        if (baseFunctions.getSystemAttributes().indexOf(projectPreferencesAttrtibute) < 0) {
            baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
            engine.updateQualifier(baseFunctions);
        }
        checkIDEF0Attributes(engine, baseFunctions);
    }
    Qualifier modelTree = createQualifier(F_MODEL_TREE);
    final Attribute name = StandardAttributesPlugin.getAttributeNameAttribute(engine);
    if (justCreated) {
        modelTree.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
        modelTree.getSystemAttributes().add(StandardAttributesPlugin.getAttributeQualifierId(engine));
        modelTree.getAttributes().add(name);
        modelTree.setAttributeForName(name.getId());
        engine.updateQualifier(modelTree);
        checkModelTree(modelTree);
    }
    if (!StandardAttributesPlugin.isDisableAutoupdate(engine)) {
        engine.addElementAttributeListener(modelTree, new ElementAttributeListener() {

            @Override
            public void attributeChanged(AttributeEvent event) {
                if (event.isJournaled())
                    return;
                if (name.equals(event.getAttribute())) {
                    Long id = (Long) engine.getAttribute(event.getElement(), StandardAttributesPlugin.getAttributeQualifierId(engine));
                    if (id != null) {
                        Qualifier model = engine.getQualifier(id);
                        if (model != null) {
                            model.setName(String.valueOf(event.getNewValue()));
                            engine.updateQualifier(model);
                        }
                    }
                }
            }
        });
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementAttributeListener(com.ramussoft.common.event.ElementAttributeListener) Element(com.ramussoft.common.Element) AttributeEvent(com.ramussoft.common.event.AttributeEvent) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier)

Example 45 with Qualifier

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

the class IDEF0Plugin method setDefaultRectangleVisualOptions.

public static void setDefaultRectangleVisualOptions(Engine engine, Element element, RectangleVisualOptions ops) {
    Qualifier qualifier = engine.getQualifier(element.getQualifierId());
    if (!hasVisualAttributes(engine, qualifier)) {
        addVisualAttributes(engine, qualifier);
        engine.updateQualifier(qualifier);
    }
    engine.setAttribute(element, getAttribute(engine, F_BOUNDS), ops.bounds);
    engine.setAttribute(element, getAttribute(engine, F_BACKGROUND), ops.background);
    engine.setAttribute(element, getAttribute(engine, F_FOREGROUND), ops.foreground);
    engine.setAttribute(element, getAttribute(engine, F_FONT), ops.font);
}
Also used : Qualifier(com.ramussoft.common.Qualifier)

Aggregations

Qualifier (com.ramussoft.common.Qualifier)157 Attribute (com.ramussoft.common.Attribute)72 Element (com.ramussoft.common.Element)59 ArrayList (java.util.ArrayList)45 Engine (com.ramussoft.common.Engine)22 Row (com.ramussoft.database.common.Row)17 Row (com.ramussoft.pb.Row)14 List (java.util.List)12 Hashtable (java.util.Hashtable)11 QualifierEvent (com.ramussoft.common.event.QualifierEvent)10 ResultSet (java.sql.ResultSet)9 SQLException (java.sql.SQLException)9 AttributeType (com.ramussoft.common.AttributeType)8 RowSet (com.ramussoft.database.common.RowSet)8 DataPlugin (com.ramussoft.pb.DataPlugin)8 NFunction (com.ramussoft.pb.data.negine.NFunction)8 AttributeEvent (com.ramussoft.common.event.AttributeEvent)7 Journaled (com.ramussoft.common.journal.Journaled)7 RowMapper (com.ramussoft.jdbc.RowMapper)7 IEngine (com.ramussoft.common.IEngine)6