Search in sources :

Example 1 with IEngine

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

the class BaseExporter method export.

/**
 * @param args
 * @throws IOException
 */
public void export(final File file) throws IOException {
    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 File getFile() {
            return null;
        }

        @Override
        public Connection createConnection() throws SQLException {
            return EngineFactory.createNewConnection();
        }

        @Override
        protected String getJournalDirectoryName(String tmp) {
            return null;
        }

        @Override
        protected FileIEngineImpl createFileIEngine(PluginFactory factory) throws ClassNotFoundException, ZipException, IOException {
            return new FileIEngineImpl(0, template, factory, null);
        }
    };
    Engine s = database.getEngine(null);
    FileIEngineImpl impl = (FileIEngineImpl) s.getDeligate();
    EngineFactory factory = new EngineFactory();
    IEngine d = factory.getEngine();
    ZipOutputStream out = impl.saveToFileNotCloseFile(file);
    for (String streamName : d.getStreamNames()) {
        byte[] bs = d.getStream(streamName);
        if (bs == null) {
        } else {
            if (streamName.startsWith("/"))
                streamName = streamName.substring(1);
            out.putNextEntry(new ZipEntry(streamName));
            out.write(bs);
        }
    }
    out.close();
    try {
        factory.getTemplate().getConnection().close();
        impl.getConnection().close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) IEngine(com.ramussoft.common.IEngine) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) PluginProvider(com.ramussoft.common.PluginProvider) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) ZipException(java.util.zip.ZipException) IOException(java.io.IOException) SQLException(java.sql.SQLException) ZipOutputStream(java.util.zip.ZipOutputStream) MemoryDatabase(com.ramussoft.database.MemoryDatabase) PluginFactory(com.ramussoft.common.PluginFactory) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine)

Example 2 with IEngine

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

the class EvalPlugin method init.

@Override
public void init(final Engine engine, AccessRules rules) {
    super.init(engine, rules);
    Qualifier qualifier = StandardAttributesPlugin.getQualifiersQualifier(engine);
    engine.setPluginProperty(getName(), "Plugin", this);
    function = getFunction(qualifier);
    if (function == null) {
        function = engine.createSystemAttribute(new AttributeType(EVAL, "Function", false));
        function.setName(FUNCTION_ATTRIBUTE);
        engine.updateAttribute(function);
        qualifier.getSystemAttributes().add(function);
        engine.updateQualifier(qualifier);
    }
    functionDependences = engine.getSystemQualifier(QUALIFIER_EVAL_FUNCTION_DEPENDENCES);
    if (functionDependences == null) {
        createEvalObjects(engine);
    } else {
        functionDependence = engine.getSystemAttribute(ATTRIBUTE_EVAL_FUNCTION_DEPENDENCE);
        functionDependenceQualifier = engine.getSystemAttribute(ATTRIBUTE_EVAL_DEPENDENCE_QUALIFIER);
        functionDependenceAttribute = engine.getSystemAttribute(ATTRIBUTE_EVAL_DEPENDENCE_ATTRIBUTE);
        functionDependenceSourceAttribute = engine.getSystemAttribute(ATTRIBUTE_EVAL_FUNCTION_DEPENDENCE_SOURCE_ATTRIBUTE);
    }
    if (!StandardAttributesPlugin.isDisableAutoupdate(engine)) {
        final Util util = Util.getUtils(engine);
        util.getScriptHolders().addFunctionsChangeListener(new FunctionsChangeListener() {

            @SuppressWarnings("unchecked")
            @Override
            public void functionsChanged(FunctionsChangeEvent event) {
                IEngine iEngine = engine.getDeligate();
                if ((iEngine != null) && (iEngine instanceof IEngineImpl)) {
                    JDBCTemplate template = ((IEngineImpl) iEngine).getTemplate();
                    String prefix = ((IEngineImpl) iEngine).getPrefix();
                    for (String function : event.getFunctionNames()) {
                        List<FunctionPersistent> list = template.query("SELECT function, qualifier_attribute_id, qualifier_table_attribute_id, autochange, attribute_id, element_id FROM " + prefix + "attribute_functions WHERE function LIKE ? AND autochange=1", new RowMapper() {

                            @Override
                            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                                FunctionPersistent persistent = new FunctionPersistent(rs.getString(1), rs.getLong(2), rs.getLong(3), rs.getInt(4));
                                persistent.setAttributeId(rs.getLong(5));
                                persistent.setElementId(rs.getLong(6));
                                return persistent;
                            }
                        }, new Object[] { "%" + function + "%" }, true);
                        for (FunctionPersistent fp : list) {
                            recalculateQualifierAttribute(engine, StandardAttributesPlugin.getQualifier(engine, engine.getElement(fp.getElementId())), util, fp);
                        }
                    }
                }
                for (String function : event.getFunctionNames()) {
                    for (CalculateInfo info : engine.findCalculateInfos("%" + function + "%", true)) {
                        recalculate(engine, info);
                    }
                }
            }
        });
        engine.addElementAttributeListener(null, new ElementAttributeListener() {

            @SuppressWarnings("unchecked")
            @Override
            public void attributeChanged(AttributeEvent event) {
                if (event.isJournaled())
                    return;
                if (DISABLE_RECALC)
                    return;
                if (event.getElement() == null) {
                    IEngine d = engine.getDeligate();
                    List<Element> allElements = null;
                    if ((d != null) && (d instanceof IEngineImpl)) {
                        JDBCTemplate template = ((IEngineImpl) d).getTemplate();
                        String prefix = ((IEngineImpl) d).getPrefix();
                        allElements = template.query("SELECT * FROM " + prefix + "elements WHERE qualifier_id in\n" + "(SELECT qualifier_id FROM " + prefix + "qualifiers_attributes WHERE attribute_id=?)", new RowMapper() {

                            @Override
                            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                                return new Element(rs.getLong("element_id"), rs.getLong("qualifier_id"), rs.getString("element_name"));
                            }
                        }, new Object[] { event.getAttribute().getId() }, true);
                    } else {
                        Attribute attribute = event.getAttribute();
                        allElements = new ArrayList<Element>();
                        for (Qualifier qualifier : engine.getQualifiers()) {
                            if (qualifier.getAttributes().indexOf(attribute) >= 0) {
                                allElements.addAll(engine.getElements(qualifier.getId()));
                            }
                        }
                    }
                    Attribute attribute = event.getAttribute();
                    for (Element element : allElements) {
                        recalculateElement(engine, new AttributeEvent(engine, element, attribute, null, null));
                    }
                } else
                    recalculateElement(engine, event);
            }

            private void recalculateElement(final Engine engine, AttributeEvent event) {
                MetaValue metaValue = new MetaValue(event.getElement().getId(), event.getAttribute().getId());
                List<MetaValue> metaValueList = hashtable.get(Thread.currentThread());
                if (metaValueList == null) {
                    metaValueList = new ArrayList<MetaValue>();
                    hashtable.put(Thread.currentThread(), metaValueList);
                } else {
                    if (metaValueList.indexOf(metaValue) >= 0)
                        return;
                }
                metaValueList.add(metaValue);
                try {
                    for (CalculateInfo info : engine.getDependences(event.getElement().getId(), event.getAttribute().getId(), true)) {
                        recalculate(engine, info);
                    }
                    List<Element> elements = engine.findElements(functionDependences.getId(), functionDependence, event.getElement().getId());
                    for (Element e : elements) {
                        Qualifier qualifier = engine.getQualifier((Long) engine.getAttribute(e, functionDependenceQualifier));
                        Attribute attribute = engine.getAttribute((Long) engine.getAttribute(e, functionDependenceAttribute));
                        if ((qualifier != null) && (attribute != null)) {
                            Element el = StandardAttributesPlugin.getElement(event.getEngine(), qualifier.getId());
                            if (el != null)
                                for (Element child : engine.getElements(qualifier.getId())) {
                                    recalculateInQualifier(engine, Util.elementIdToValue(event.getElement().getId(), event.getAttribute().getId()), null, el, child);
                                }
                        }
                    }
                    Element element = StandardAttributesPlugin.getElement(event.getEngine(), event.getElement().getQualifierId());
                    if (element == null) {
                        Qualifier qualifier = engine.getQualifier(event.getElement().getQualifierId());
                        if (StandardAttributesPlugin.isTableQualifier(qualifier)) {
                            Element parent = StandardAttributesPlugin.getElementForTableElement(engine, event.getElement());
                            if (parent == null)
                                return;
                            Qualifier main = engine.getQualifier(parent.getQualifierId());
                            Attribute tableAttribute = null;
                            for (Attribute attr : main.getAttributes()) {
                                if (StandardAttributesPlugin.getTableQualifeirName(attr).equals(qualifier.getName())) {
                                    tableAttribute = attr;
                                    break;
                                }
                            }
                            if (tableAttribute == null)
                                return;
                            element = StandardAttributesPlugin.getElement(event.getEngine(), parent.getQualifierId());
                            if (element != null) {
                                if (event.getAttribute().equals(StandardAttributesPlugin.getTableElementIdAttribute(engine)))
                                    recalculateInQualifier(engine, null, event.getElement(), element, parent);
                                else
                                    recalculateInQualifier(engine, Util.tableAttributeToValue(tableAttribute.getId(), event.getAttribute().getId()), event.getElement(), element, parent);
                            }
                        }
                        return;
                    }
                    recalculateInQualifier(engine, Util.attributeIdToValue(event.getAttribute().getId()), null, element, event.getElement());
                } finally {
                    metaValueList.remove(metaValueList.size() - 1);
                }
            }
        });
        engine.addElementListener(null, new ElementAdapter() {

            @SuppressWarnings("unchecked")
            @Override
            public void elementCreated(ElementEvent event) {
                if (event.isJournaled())
                    return;
                Element element = StandardAttributesPlugin.getElement(event.getEngine(), event.getNewElement().getQualifierId());
                if (element == null) {
                    return;
                }
                List<FunctionPersistent> list = getFunctionAttribute(engine, element);
                if (list == null)
                    return;
                Util utils = Util.getUtils(engine);
                for (FunctionPersistent fp : list) if (fp.getAutochange() != 0) {
                    Eval eval = new Eval(fp.getFunction());
                    try {
                        utils.fillAttributes(eval, engine.getQualifier(event.getNewElement().getQualifierId()), event.getNewElement(), null, null, null, true);
                        utils.fillResult(fp.getQualifierAttributeId(), eval, event.getNewElement());
                    } catch (Exception e) {
                        utils.fillResult(fp.getQualifierAttributeId(), e, event.getNewElement());
                        if (e instanceof RuntimeException)
                            throw (RuntimeException) e;
                        throw new RuntimeException(e);
                    } finally {
                    }
                }
            }

            @SuppressWarnings("unchecked")
            @Override
            public void beforeElementDeleted(final ElementEvent event) {
                if ((event.isJournaled()) || (event.getNewElement() != null))
                    return;
                Element oldElement = event.getOldElement();
                Qualifier qualifier = engine.getQualifier(oldElement.getQualifierId());
                for (Attribute attribute : qualifier.getAttributes()) {
                    removeAttributeFromCalculateInfo(engine, oldElement, attribute);
                    CalculateInfo info = engine.getCalculateInfo(oldElement.getId(), attribute.getId());
                    if (info != null) {
                        info.setFormula(null);
                        engine.setCalculateInfo(info);
                    }
                }
                List<Element> elements = engine.findElements(functionDependences.getId(), functionDependence, oldElement.getId());
                Vector<Long> qualifiers = new Vector<Long>(elements.size());
                final String start = Util.ELEMENT_PREFIX + oldElement.getId();
                for (Element element : elements) {
                    Long q = (Long) engine.getAttribute(element, functionDependenceQualifier);
                    if (qualifiers.indexOf(q) < 0) {
                        qualifiers.add(q);
                        Element qElement = StandardAttributesPlugin.getElement(engine, q.longValue());
                        List<FunctionPersistent> fpl = (List<FunctionPersistent>) engine.getAttribute(qElement, function);
                        for (FunctionPersistent fp : fpl) {
                            try {
                                Eval eval = new Eval(fp.getFunction());
                                eval.replaceValueNames(new Replacementable() {

                                    @Override
                                    public String getNewName(String oldName) {
                                        if (oldName.startsWith(start))
                                            return "NULL";
                                        return oldName;
                                    }
                                });
                                fp.setFunction(eval.toString());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        engine.setAttribute(qElement, function, fpl);
                    }
                // engine.deleteElement(element.getId());
                }
            }
        });
        engine.addQualifierListener(new QualifierAdapter() {

            @SuppressWarnings("unchecked")
            @Override
            public void beforeQualifierUpdated(QualifierEvent event) {
                List<Attribute> rem = new ArrayList<Attribute>();
                for (Attribute a : event.getOldQualifier().getAttributes()) {
                    if (event.getNewQualifier().getAttributes().indexOf(a) < 0)
                        rem.add(a);
                }
                if (rem.size() > 0) {
                    List<Element> list = engine.getElements(event.getOldQualifier().getId());
                    for (Attribute attribute : rem) {
                        for (Element element : list) {
                            removeAttributeFromCalculateInfo(engine, element, attribute);
                            CalculateInfo info = engine.getCalculateInfo(element.getId(), attribute.getId());
                            if (info != null) {
                                info.setFormula(null);
                                engine.setCalculateInfo(info);
                            }
                        }
                        List<Element> elements = engine.findElements(functionDependences.getId(), functionDependenceSourceAttribute, attribute.getId());
                        final String end = Util.ATTRIBUTE_PREFIX + attribute.getId();
                        for (Element element : elements) {
                            Long id = (Long) engine.getAttribute(element, functionDependence);
                            if (engine.getQualifierIdForElement(id) == event.getNewQualifier().getId()) {
                                Long qId = (Long) engine.getAttribute(element, functionDependenceQualifier);
                                Element element2 = StandardAttributesPlugin.getElement(engine, qId);
                                List<FunctionPersistent> fpl = (List<FunctionPersistent>) engine.getAttribute(element2, function);
                                for (FunctionPersistent fp : fpl) {
                                    Eval eval = new Eval(fp.getFunction());
                                    eval.replaceValueNames(new Replacementable() {

                                        @Override
                                        public String getNewName(String oldName) {
                                            if (oldName.endsWith(end)) {
                                                return "NULL";
                                            }
                                            return oldName;
                                        }
                                    });
                                    fp.setFunction(eval.toString());
                                }
                                engine.setAttribute(element2, function, fpl);
                            }
                        }
                    }
                }
            }

            @Override
            public void qualifierDeleted(QualifierEvent event) {
                Qualifier qualifier = event.getOldQualifier();
                for (Element element : engine.findElements(functionDependences.getId(), functionDependenceQualifier, qualifier.getId())) {
                    engine.deleteElement(element.getId());
                }
            }
        });
        Qualifier qq = StandardAttributesPlugin.getQualifiersQualifier(engine);
        engine.addElementAttributeListener(qq, new ElementAttributeListener() {

            @Override
            public void attributeChanged(AttributeEvent event) {
                if (event.isJournaled())
                    return;
                if (function.equals(event.getAttribute())) {
                    recalculateFunctionOfQualifier(engine, event);
                }
            }
        });
        engine.addFormulaListener(new FormulaListener() {

            @Override
            public void formulaChanged(FormulaEvent event) {
                if (event.isJournaled())
                    return;
                CalculateInfo info = event.getNewFormula();
                recalculate(engine, info);
            }
        });
    }
}
Also used : ElementAdapter(com.ramussoft.common.event.ElementAdapter) SQLException(java.sql.SQLException) Attribute(com.ramussoft.common.Attribute) ElementAttributeListener(com.ramussoft.common.event.ElementAttributeListener) Element(com.ramussoft.common.Element) IEngine(com.ramussoft.common.IEngine) ArrayList(java.util.ArrayList) Util(com.ramussoft.eval.Util) QualifierEvent(com.ramussoft.common.event.QualifierEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent) JDBCTemplate(com.ramussoft.jdbc.JDBCTemplate) AttributeType(com.ramussoft.common.AttributeType) ResultSet(java.sql.ResultSet) Qualifier(com.ramussoft.common.Qualifier) ArrayList(java.util.ArrayList) List(java.util.List) Replacementable(com.ramussoft.eval.Replacementable) FunctionPersistent(com.ramussoft.eval.FunctionPersistent) FormulaEvent(com.ramussoft.common.event.FormulaEvent) Eval(com.ramussoft.eval.Eval) Vector(java.util.Vector) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine) RowMapper(com.ramussoft.jdbc.RowMapper) QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) MetaValue(com.ramussoft.eval.MetaValue) ElementEvent(com.ramussoft.common.event.ElementEvent) SQLException(java.sql.SQLException) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) FunctionsChangeListener(com.ramussoft.eval.event.FunctionsChangeListener) FunctionsChangeEvent(com.ramussoft.eval.event.FunctionsChangeEvent) CalculateInfo(com.ramussoft.common.CalculateInfo) FormulaListener(com.ramussoft.common.event.FormulaListener) EObject(com.ramussoft.eval.EObject)

Example 3 with IEngine

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

the class VariantPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new AbstractAttributeConverter() {

        @SuppressWarnings("unchecked")
        public Object toObject(java.util.List<Persistent>[] persistents, long elementId, long attributeId, IEngine engine) {
            if (elementId < 0) {
                List list = persistents[0];
                if (list != null)
                    Collections.sort(list);
                return persistents[0];
            } else {
                List<Persistent> list = persistents[0];
                if (list.size() != 1)
                    return null;
                List<Persistent> ps = engine.getBinaryAttribute(-1, attributeId)[0];
                VariantPersistent vp = (VariantPersistent) list.get(0);
                for (Persistent p : ps) {
                    VariantPropertyPersistent pp = (VariantPropertyPersistent) p;
                    if (pp.getVariantId() == vp.getVariantId())
                        return pp.getValue();
                }
                return "WARNING: Unknown variant with variant id: " + vp.getVariantId();
            }
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<Persistent>[] toPersistens(Object object, long elementId, long attributeId, IEngine engine) {
            if (elementId < 0) {
                List<VariantPropertyPersistent> list = (List) object;
                for (int i = 0; i < list.size(); i++) list.get(i).setPosition(i);
                return new List[] { list };
            } else {
                if (object == null) {
                    return new List[] { new ArrayList(0) };
                }
                List<Persistent> ps = engine.getBinaryAttribute(-1, attributeId)[0];
                VariantPersistent vp = new VariantPersistent();
                long maxId = -1;
                for (Persistent p : ps) {
                    VariantPropertyPersistent pp = (VariantPropertyPersistent) p;
                    if (pp.getValue().equals(object)) {
                        vp.setVariantId(pp.getVariantId());
                        List<Persistent> list = new ArrayList<Persistent>(1);
                        list.add(vp);
                        return new List[] { list };
                    }
                    if (maxId < pp.getVariantId())
                        maxId = pp.getVariantId();
                }
                VariantPropertyPersistent pp = new VariantPropertyPersistent();
                pp.setValue((String) object);
                pp.setVariantId(maxId + 1l);
                pp.setAttribute(attributeId);
                pp.setPosition(ps.size());
                vp.setVariantId(pp.getVariantId());
                if (engine instanceof Engine) {
                    ps.add(pp);
                    ((Engine) engine).setAttribute(null, engine.getAttribute(attributeId), ps);
                } else {
                    Transaction transaction = new Transaction();
                    transaction.getSave().add(pp);
                    engine.setBinaryAttribute(-1, attributeId, transaction);
                }
                List<Persistent> list = new ArrayList<Persistent>(1);
                list.add(vp);
                return new List[] { list };
            }
        }
    };
}
Also used : IEngine(com.ramussoft.common.IEngine) ArrayList(java.util.ArrayList) Persistent(com.ramussoft.common.persistent.Persistent) Transaction(com.ramussoft.common.persistent.Transaction) List(java.util.List) ArrayList(java.util.ArrayList) AbstractAttributeConverter(com.ramussoft.common.attribute.AbstractAttributeConverter) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine)

Example 4 with IEngine

use of com.ramussoft.common.IEngine 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 5 with IEngine

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

the class ProjectPreferencesPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new AbstractAttributeConverter() {

        @Override
        public Object toObject(List<Persistent>[] persistents, long elementId, long attributeId, IEngine engine) {
            ProjectOptions result;
            if (persistents[0].size() == 0)
                return null;
            else
                result = new ProjectOptions((IDEF0ModelPreferencesPersistent) persistents[0].get(0));
            for (Persistent p : persistents[1]) result.getReadedModel().addReaded().setDeligate((ReaderPersistent) p);
            return result;
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<Persistent>[] toPersistens(Object object, long elementId, long attributeId, IEngine engine) {
            ProjectOptions po = (ProjectOptions) object;
            List<Persistent>[] res = new List[2];
            List<Persistent> f = new ArrayList<Persistent>();
            f.add(po.getDeligate());
            res[0] = f;
            List<Persistent> s = new ArrayList<Persistent>();
            for (Readed r : po.getReadedModel().getAllReaded()) {
                s.add(r.getDeligate());
            }
            res[1] = s;
            return res;
        }
    };
}
Also used : IEngine(com.ramussoft.common.IEngine) ArrayList(java.util.ArrayList) Persistent(com.ramussoft.common.persistent.Persistent) List(java.util.List) ArrayList(java.util.ArrayList) AbstractAttributeConverter(com.ramussoft.common.attribute.AbstractAttributeConverter) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) Readed(com.dsoft.pb.idef.elements.Readed)

Aggregations

IEngine (com.ramussoft.common.IEngine)15 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Engine (com.ramussoft.common.Engine)6 Persistent (com.ramussoft.common.persistent.Persistent)6 AbstractAttributeConverter (com.ramussoft.common.attribute.AbstractAttributeConverter)5 IOException (java.io.IOException)4 PluginProvider (com.ramussoft.common.PluginProvider)3 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)3 SQLException (java.sql.SQLException)3 Attribute (com.ramussoft.common.Attribute)2 Element (com.ramussoft.common.Element)2 PluginFactory (com.ramussoft.common.PluginFactory)2 Qualifier (com.ramussoft.common.Qualifier)2 CachedEngine (com.ramussoft.common.cached.CachedEngine)2 Command (com.ramussoft.common.journal.command.Command)2 CreateAttributeCommand (com.ramussoft.common.journal.command.CreateAttributeCommand)2 CreateElementCommand (com.ramussoft.common.journal.command.CreateElementCommand)2 CreateQualifierCommand (com.ramussoft.common.journal.command.CreateQualifierCommand)2 DeleteAttributeCommand (com.ramussoft.common.journal.command.DeleteAttributeCommand)2