Search in sources :

Example 86 with Element

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

the class HTTPParser method printReportsList.

/**
 * Друкує список звітів з посиланнями на них.
 *
 * @throws IOException
 */
protected void printReportsList() throws IOException {
    Engine engine = dataPlugin.getEngine();
    Qualifier qualifier = ReportPlugin.getReportsQualifier(engine);
    Attribute name = ReportPlugin.getReportNameAttribute(engine);
    RowSet rowSet = new RowSet(engine, qualifier, new Attribute[] { name }, null, true);
    List<Element> reports = ((ReportQuery) engine).getHTMLReports();
    if (reports.size() == 0)
        return;
    printMainTableTitle(RES.getString("reportsTitle"));
    for (com.ramussoft.database.common.Row element : rowSet.getAllRows()) {
        htmlStream.println("<tr>");
        htmlStream.println("<td colspan=2>");
        printStartATeg("reportsq/index.html?num=" + element.getElementId());
        htmlStream.println(element.getCode());
        printEndATeg();
        printStartATeg("reportsq/index.html?num=" + element.getElementId());
        htmlStream.print(element.getName());
        printEndATeg();
        htmlStream.println("</td>");
        htmlStream.println("</tr>");
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine)

Example 87 with Element

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

the class HTTPParser method printRowBase.

private void printRowBase(final Row row) throws IOException {
    htmlStream.print("<canter><h2 class=\"Ramus\">");
    if (row instanceof Function)
        htmlStream.print(MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) row) + " " + row.getName());
    else
        htmlStream.print(row.getKod() + ". " + row.getName());
    if (row.isElement()) {
        Element element = StandardAttributesPlugin.getElement(dataPlugin.getEngine(), row.getElement().getQualifierId());
        if (element != null) {
            htmlStream.print(" [");
            printStartATeg("rows/index.html?id=" + element.getId());
            htmlStream.print(element.getName());
            printEndATeg();
            htmlStream.print("]");
        }
    }
    htmlStream.println("</h2></canter>");
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Element(com.ramussoft.common.Element)

Example 88 with Element

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

the class AnyToAnyPlugin method getElementName.

private String getElementName(final IEngine engine, final HashMap<Long, Attribute> attributesCache, final HashMap<Long, Qualifier> qualifiersCache, ResultSet rs) throws SQLException {
    Element element = engine.getElement(rs.getLong("element_id"));
    if (element == null)
        return "";
    Qualifier qualifier;
    if (!qualifiersCache.containsKey(element.getQualifierId())) {
        qualifier = engine.getQualifier(element.getQualifierId());
        qualifiersCache.put(element.getQualifierId(), qualifier);
    } else
        qualifier = qualifiersCache.get(element.getQualifierId());
    if (qualifier == null || qualifier.getAttributeForName() < 0l)
        return "";
    Attribute attribute;
    if (!attributesCache.containsKey(qualifier.getAttributeForName())) {
        attribute = engine.getAttribute(qualifier.getAttributeForName());
        attributesCache.put(qualifier.getAttributeForName(), attribute);
    } else
        attribute = attributesCache.get(qualifier.getAttributeForName());
    if (attribute == null)
        return "";
    List<Persistent>[] bAttribute = engine.getBinaryAttribute(element.getId(), attribute.getId());
    if (bAttribute.length == 0)
        return "";
    List<Persistent> list = bAttribute[0];
    if (list.size() == 0)
        return "";
    if (list.get(0) instanceof TextPersistent)
        return String.valueOf(((TextPersistent) list.get(0)).getValue());
    else if (list.get(0) instanceof DFDSName)
        return String.valueOf(((DFDSName) list.get(0)).getShortName());
    return "";
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) ArrayList(java.util.ArrayList) List(java.util.List) TextPersistent(com.ramussoft.core.attribute.simple.TextPersistent) Persistent(com.ramussoft.common.persistent.Persistent) TextPersistent(com.ramussoft.core.attribute.simple.TextPersistent)

Example 89 with Element

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

the class JournaledEngine method setElementQualifier.

@Override
public void setElementQualifier(long elementId, long qualifierId) {
    qualifirsForElements.remove(elementId);
    Element element = getElement(elementId);
    Qualifier current = getQualifier(element.getQualifierId());
    Qualifier newQualifier = getQualifier(qualifierId);
    final List<Attribute> attrs = new ArrayList<Attribute>();
    addNotPresentAttributes(current.getAttributes(), newQualifier.getAttributes(), attrs);
    addNotPresentAttributes(current.getSystemAttributes(), newQualifier.getSystemAttributes(), attrs);
    Transaction[] data = getAttributesWhatWillBeDeleted(elementId, attrs);
    ElementEvent event = new ElementEvent(this, element, new Element(element.getId(), qualifierId, element.getName()), element.getQualifierId());
    beforeElementDeleted(event);
    deligate.setElementQualifier(elementId, qualifierId);
    synchronized (swithJournalLock) {
        journal.store(new SetElementQualifierCommand(this, element.getQualifierId(), qualifierId, elementId, data));
    }
    elementDeleted(event);
    event = new ElementEvent(this, element, new Element(element.getId(), qualifierId, element.getName()), qualifierId);
    qualifirsForElements.remove(element.getId());
    elementCreated(event);
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) SetElementQualifierCommand(com.ramussoft.common.journal.command.SetElementQualifierCommand) Qualifier(com.ramussoft.common.Qualifier) ElementEvent(com.ramussoft.common.event.ElementEvent)

Example 90 with Element

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

the class JournaledEngine method updateElementNames.

public void updateElementNames(Qualifier old, Qualifier qualifier) {
    if (qualifier == null)
        return;
    if ((old == null) || (old.getAttributeForName() != qualifier.getAttributeForName())) {
        Attribute attr = getAttribute(qualifier.getAttributeForName());
        if (attr != null) {
            List<Attribute> list = new ArrayList<Attribute>(1);
            list.add(attr);
            Hashtable<Element, Object[]> hash = getElements(qualifier, list);
            List<Element> elements = new ArrayList<Element>(hash.size());
            for (Entry<Element, Object[]> entry : hash.entrySet()) {
                Element element = entry.getKey();
                if (entry.getValue()[0] == null) {
                    element.setName("");
                } else {
                    element.setName(entry.getValue()[0].toString());
                }
                elements.add(element);
            }
        } else {
            List<Element> list = getElements(qualifier.getId());
            for (Element e : list) {
                e.setName("");
            }
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6