Search in sources :

Example 41 with Row

use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.

the class SectorCorrector method run.

public void run(Engine engine, AccessRules accessRules) {
    ((Journaled) engine).startUserTransaction();
    log("Loading data");
    List<Qualifier> list = IDEF0Plugin.getBaseQualifiers(engine);
    for (Qualifier q : list) {
        DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(q, engine, accessRules);
        Vector<Row> v = dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true);
        for (Row r : v) {
            if (r.getChildCount() == 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                while (sr.getSectorsCount() > 0) {
                    sr.getSector(0).remove();
                }
                sr.saveToFunction();
                log("Function " + r + " clean");
            }
        }
        for (Row r : v) {
            if (r.getChildCount() != 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                for (int i = 0; i < sr.getSectorsCount(); i++) {
                    PaintSector ps = sr.getSector(i);
                    if ((ps.getSector().getStart().getFunction() != null) && (ps.getSector().getStart().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, true);
                    if ((ps.getSector().getEnd().getFunction() != null) && (ps.getSector().getEnd().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, false);
                }
                log("Function " + r + " done");
            }
        }
    }
    ((Journaled) engine).commitUserTransaction();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) Journaled(com.ramussoft.common.journal.Journaled) Function(com.ramussoft.pb.Function) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin)

Example 42 with Row

use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method getQualifier.

@Override
public Qualifier getQualifier(long qualifierId) {
    Qualifier q = qHash.get(qualifierId);
    if (q != null)
        return q;
    Row row = rowForQualifiers.get(qualifierId);
    if (row == null)
        return null;
    if (q == null) {
        try {
            q = StandardAttributesPlugin.getQualifier(toEngine, getRow(row).getElement());
            qHash.put(qualifierId, q);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return q;
}
Also used : Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 43 with Row

use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method loadFromParalel.

public void loadFromParalel(Function base, boolean importAll, List<Qualifier> selected) {
    this.base = base;
    List<Attribute> tAttrs = toEngine.getAttributes();
    List<Attribute> fAttrs = fromEngine.getAttributes();
    for (Attribute f : fAttrs) for (Attribute t : tAttrs) if ((f.getName().equals(t.getName())) && (f.getAttributeType().equals(t.getAttributeType())))
        attrHash.put(f.getId(), t);
    List<Qualifier> fList = fromEngine.getQualifiers();
    List<Qualifier> tList = toEngine.getQualifiers();
    for (Qualifier f : fList) if (!IDEF0Plugin.isFunction(f))
        for (Qualifier t : tList) if (!IDEF0Plugin.isFunction(t))
            if (f.getName().equals(t.getName()))
                qHash.put(f.getId(), t);
    Vector<Row> fRows = fromDataPlugin.getRecChilds(null, false);
    Vector<Row> tRows = toDataPlugin.getRecChilds(null, false);
    for (Row f : fRows) {
        for (Row t : tRows) {
            if (f.getName().equals(t.getName())) {
                rowHash.put(f.getElement().getId(), t);
                Vector<Row> fCRows = fromDataPlugin.getRecChilds(f, true);
                Vector<Row> tCRows = toDataPlugin.getRecChilds(t, true);
                for (Row fc : fCRows) for (Row tc : tCRows) if (fc.getName().equals(tc.getName()))
                    rowHash.put(fc.getElement().getId(), tc);
            }
        }
    }
    if (importAll)
        createAllRows();
    for (Qualifier qualifier : selected) {
        fromDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, fromEngine, fromDataPlugin.getAccessRules());
        List<Attribute> list = getAttributes(qualifier.getAttributes());
        Qualifier baseFunction = toEngine.getQualifier(base.getElement().getQualifierId());
        for (Attribute a : list) if (baseFunction.getAttributes().indexOf(a) < 0)
            baseFunction.getAttributes().add(a);
        toEngine.updateQualifier(baseFunction);
        int r;
        if ((r = fromDataPlugin.getBaseFunction().getChildCount()) > 0)
            for (int i = 0; i < r; i++) {
                function = (Function) fromDataPlugin.getBaseFunction().getChildAt(i);
                Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
                childs.add(0, function);
                for (Row row : childs) {
                    NFunction dest = (NFunction) getRow(row);
                    showMessageAnimation(dest.toString());
                }
                NFunction func = (NFunction) getRow(function);
                createSectorsOnUpperLevel(func);
            }
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 44 with Row

use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method createParalel.

public void createParalel(final Function function, final boolean createAllRows) {
    ModelParaleler.this.function = function;
    if (createAllRows)
        createAllRows();
    Qualifier qualifier = toEngine.createQualifier();
    copyQualifier(function.getQualifier(), qualifier);
    IDEF0Plugin.installFunctionAttributes(qualifier, toEngine);
    Qualifier q = IDEF0Plugin.getModelTree(toEngine);
    Element element = toEngine.createElement(q.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(toEngine), qualifier.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(toEngine), function.getName());
    toDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, toEngine, toDataPlugin.getAccessRules());
    ModelParaleler.this.base = toDataPlugin.getBaseFunction();
    Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
    ProjectOptions projectOptions = toDataPlugin.getBaseFunction().getProjectOptions();
    projectOptions.getDeligate().setDiagramSize(function.getProjectOptions().getDeligate().getDiagramSize());
    toDataPlugin.getBaseFunction().setProjectOptions(projectOptions);
    for (Row row : childs) {
        NFunction dest = (NFunction) getRow(row);
        showMessageAnimation(dest.toString());
    }
    NFunction func = null;
    Vector<Row> v = toDataPlugin.getChilds(base, true);
    if (v.size() > 0)
        func = (NFunction) v.get(0);
    createSectorsOnUpperLevel(func);
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 45 with Row

use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method init.

@SuppressWarnings("deprecation")
private void init() {
    Vector<Row> v = fromDataPlugin.getRecChilds(null, false);
    for (Row r : v) {
        long qualifierId = StandardAttributesPlugin.getQualifierId(fromEngine, r.getElement());
        rowForQualifiers.put(qualifierId, r);
    }
    Qualifier bs = IDEF0Plugin.getBaseStreamQualifier(fromEngine);
    rowForQualifiers.put(bs.getId(), fromDataPlugin.getBaseStream());
    List<Attribute> attrs = fromEngine.getSystemAttributes();
    List<Attribute> dAttrs = toEngine.getSystemAttributes();
    Hashtable<String, Attribute> hash = new Hashtable<String, Attribute>();
    for (Attribute attribute : dAttrs) hash.put(attribute.getName(), attribute);
    for (Attribute a : attrs) {
        Attribute d = hash.get(a.getName());
        if (d == null)
            System.err.println("WARNING: System attribute not found in destination engine: " + a.getName() + " type: " + a.getAttributeType());
        else
            attrHash.put(a.getId(), d);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Aggregations

Row (com.ramussoft.pb.Row)93 Function (com.ramussoft.pb.Function)35 Stream (com.ramussoft.pb.Stream)30 Vector (java.util.Vector)28 NFunction (com.ramussoft.pb.data.negine.NFunction)19 Sector (com.ramussoft.pb.Sector)15 NRow (com.ramussoft.pb.data.negine.NRow)14 Qualifier (com.ramussoft.common.Qualifier)13 Crosspoint (com.ramussoft.pb.Crosspoint)13 NSector (com.ramussoft.pb.data.negine.NSector)13 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ArrayList (java.util.ArrayList)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 Attribute (com.ramussoft.common.Attribute)9 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)9 IOException (java.io.IOException)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 Point (com.ramussoft.pb.idef.elements.Point)8 Element (com.ramussoft.common.Element)7