Search in sources :

Example 26 with Engine

use of com.ramussoft.common.Engine 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 27 with Engine

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

the class IDEF0FunctionFilter method load.

@Override
public boolean load(Element element, RowSet rowSet) {
    Engine engine = rowSet.getEngine();
    Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
    if (rowSet.getQualifier().getSystemAttributes().contains(attribute)) {
        Integer type = (Integer) engine.getAttribute(element, attribute);
        if (type != null)
            return type < 1001;
    }
    return true;
}
Also used : Attribute(com.ramussoft.common.Attribute) Engine(com.ramussoft.common.Engine)

Example 28 with Engine

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

the class HTTPParser method printClasificator.

private void printClasificator() throws IOException {
    final Row row = loadRowById();
    if (row == null) {
        printError(RES.getString("cantLoatClasificator"));
        return;
    }
    if (row instanceof Function) {
        htmlTitle = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) row) + " " + row.getName();
    } else
        htmlTitle = row.getKod() + ". " + row.getName();
    printStartD();
    printRowBase(row);
    if (row instanceof Function) {
        boolean b = true;
        if (!row.isLeaf()) {
            b = false;
            htmlStream.println("<br>");
            printStartATeg("idef0/index.html?id=" + row.getGlobalId().toString());
            htmlStream.print(RES.getString("idef0Model"));
            printEndATeg();
        }
        if (row.isElement()) {
            if (b)
                htmlStream.println("<br>");
            else
                htmlStream.print(" ");
            printStartATeg("idef0/index.html?id=" + row.getParentRow().getGlobalId().toString());
            htmlStream.print(RES.getString("ParentIDEF0Model"));
            printEndATeg();
        }
        htmlStream.println("<br>");
    } else if (row instanceof Stream && !dataPlugin.getBaseStream().equals(row)) {
        printStreamsRows((Stream) row);
    }
    boolean haveTable = false;
    Vector<Row> v = dataPlugin.getChilds(row, row.isElement());
    if (v.size() > 0) {
        if (haveTable)
            htmlStream.println("<br>");
        printElements(RES.getString("childElements"), v.toArray(), row.isElement() ? "rows" : "clasificators");
        haveTable = true;
    }
    if (!row.isElement()) {
        if (haveTable)
            htmlStream.println("<br>");
        v = dataPlugin.getRecChilds(row, true);
        htmlStream.println("<hr>");
        String var = params.get("var");
        String attr = params.get("attr");
        if (var != null) {
            Engine engine = dataPlugin.getEngine();
            long attrId = Long.parseLong(attr);
            long varId = Long.parseLong(var);
            Attribute attribute = engine.getAttribute(attrId);
            List<VariantPropertyPersistent> list = (List<VariantPropertyPersistent>) engine.getAttribute(null, attribute);
            VariantPropertyPersistent vpp = null;
            for (VariantPropertyPersistent vp : list) if (vp.getVariantId() == varId) {
                vpp = vp;
                break;
            }
            if ((vpp != null) && (vpp.getValue() != null)) {
                String value = vpp.getValue();
                ArrayList list1 = new ArrayList();
                for (Row r : v) {
                    if (value.equals(((NRow) r).getAttribute(attribute)))
                        list1.add(r);
                }
                htmlStream.println("(" + value + ")");
                htmlStream.println("<br>");
                printElements(RES.getString("childElements"), list1.toArray(), row.isElement() ? "rows" : "clasificators");
            }
        } else
            printElements(RES.getString("clasificatorElements"), v.toArray());
    } else
        printRowAttributes(row);
    if (row instanceof Function && (row.isElement())) {
        printFunctionsArrows((Function) row);
    } else if (!(row instanceof Stream)) {
        printArrowFunctionss(row);
    }
    printEndD();
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList) VariantPropertyPersistent(com.ramussoft.core.attribute.simple.VariantPropertyPersistent) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) List(java.util.List) ArrayList(java.util.ArrayList) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine)

Example 29 with Engine

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

the class HTTPParser method getReportHTMLText.

protected Source getReportHTMLText(Engine engine, Element report, Query query) {
    String page = null;
    try {
        HashMap<String, Object> map = new HashMap<String, Object>();
        ReportQuery impl;
        if (dataPlugin.getEngine().getDeligate() instanceof IEngineImpl)
            impl = new ReportQueryImpl(engine) {

                @Override
                protected Out createOut(OutputStream stream) {
                    try {
                        return new Out(stream) {

                            @Override
                            public void print(Object object) {
                                if (!printVersion) {
                                    if (object instanceof Qualifier) {
                                        Engine engine = dataPlugin.getEngine();
                                        Element element = StandardAttributesPlugin.getElement(engine, ((Qualifier) object).getId());
                                        if (element == null) {
                                            print(object.toString());
                                        } else {
                                            String href = "rows/index.html?id=" + element.getId();
                                            print(getStartATeg(href, false, true));
                                            print(object.toString());
                                            print(getEndATeg());
                                        }
                                    } else if (object instanceof Code) {
                                        String href = "rows/index.html?id=" + ((Code) object).getElement().getId();
                                        print(getStartATeg(href, false, true));
                                        print(object.toString());
                                        print(getEndATeg());
                                    } else if (object instanceof com.ramussoft.database.common.Row) {
                                        String href = "rows/index.html?id=" + ((com.ramussoft.database.common.Row) object).getElementId();
                                        print(getStartATeg(href, false, true));
                                        print(object.toString());
                                        print(getEndATeg());
                                    } else
                                        super.print(object);
                                } else
                                    super.print(object);
                            }
                        };
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    }
                }
            };
        else
            impl = (ReportQuery) dataPlugin.getEngine();
        if (query != null)
            map.put("query", query);
        page = impl.getHTMLReport(report, map);
    } catch (Exception e1) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        java.io.PrintStream s = null;
        try {
            s = new java.io.PrintStream(stream, true, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        if (e1 instanceof DataException)
            s.println(((DataException) e1).getMessage(new MessageFormatter() {

                @Override
                public String getString(String key, Object[] arguments) {
                    return MessageFormat.format(ReportResourceManager.getString(key), arguments);
                }
            }));
        else {
            s.println("<pre>");
            e1.printStackTrace(s);
            s.println("</pre>");
        }
        s.flush();
        try {
            page = new String(stream.toByteArray(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        htmlStream.println(page);
        return null;
    }
    if (!printVersion) {
        htmlStream.println("<H4>" + report.getName() + "</H4>");
    }
    Source source = new Source(page);
    source.fullSequentialParse();
    htmlStream.println(source);
    return source;
}
Also used : HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Element(com.ramussoft.common.Element) MessageFormatter(com.ramussoft.report.data.MessageFormatter) Source(net.htmlparser.jericho.Source) Qualifier(com.ramussoft.common.Qualifier) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine) ReportQuery(com.ramussoft.report.ReportQuery) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Code(com.ramussoft.report.Code) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ReportQueryImpl(com.ramussoft.report.ReportQueryImpl) Out(com.ramussoft.report.data.Out) DataException(com.ramussoft.report.data.DataException) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow)

Example 30 with Engine

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

the class SimpleAttributeViewer method printAttribute.

@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
    Engine engine = dataPlugin.getEngine();
    Object object = engine.getAttribute(element, attribute);
    if (object != null) {
        callback.beforePrint(printStream);
        printObject(printStream, object);
        callback.afterPrint(printStream);
    }
}
Also used : Engine(com.ramussoft.common.Engine)

Aggregations

Engine (com.ramussoft.common.Engine)85 Attribute (com.ramussoft.common.Attribute)32 ArrayList (java.util.ArrayList)30 Element (com.ramussoft.common.Element)27 Qualifier (com.ramussoft.common.Qualifier)22 AccessRules (com.ramussoft.common.AccessRules)21 List (java.util.List)19 IEngine (com.ramussoft.common.IEngine)15 Row (com.ramussoft.database.common.Row)13 IOException (java.io.IOException)11 SQLException (java.sql.SQLException)11 PluginFactory (com.ramussoft.common.PluginFactory)8 PluginProvider (com.ramussoft.common.PluginProvider)8 Journaled (com.ramussoft.common.journal.Journaled)8 CachedEngine (com.ramussoft.common.cached.CachedEngine)7 Hashtable (java.util.Hashtable)7 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)6 JournaledEngine (com.ramussoft.common.journal.JournaledEngine)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)5 MemoryDatabase (com.ramussoft.database.MemoryDatabase)5