Search in sources :

Example 16 with Row

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

the class NStream method saveAdded.

public void saveAdded() {
    Row[] aRows = getARows();
    List<AnyToAnyPersistent> list = new ArrayList<AnyToAnyPersistent>(aRows.length);
    int i = 0;
    for (Row row : aRows) {
        if (row != null) {
            AnyToAnyPersistent e = new AnyToAnyPersistent(((com.ramussoft.database.common.Row) row).getElementId());
            if (row.getAttachedStatus() != null && row.getAttachedStatus().trim().length() > 0)
                e.setElementStatus(row.getAttachedStatus());
            list.add(e);
            rowStatuses[i] = aRows[i].getAttachedStatus();
        }
        i++;
    }
    this.setAttribute(((NDataPlugin) dataPlugin).addedRows, list);
}
Also used : ArrayList(java.util.ArrayList) Row(com.ramussoft.pb.Row) AnyToAnyPersistent(com.ramussoft.idef0.attribute.AnyToAnyPersistent)

Example 17 with Row

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

the class AbstractSector method removeFromParent.

public void removeFromParent(Row[] rows, boolean start) {
    final Vector<Sector> v = new Vector<Sector>();
    if (start)
        getParents(getStart().getCrosspoint(), v);
    else
        getParents(getEnd().getCrosspoint(), v);
    for (int i = 0; i < v.size(); i++) {
        final AbstractSector s = (AbstractSector) v.get(i);
        final Stream ps = s.getStream();
        if (ps != null) {
            final Vector<Sector> v1 = new Vector<Sector>();
            if (s.getStart().getBorderType() < 0 && !start)
                s.getChilds(s.getStart().getCrosspoint(), v1);
            if (s.getEnd().getBorderType() < 0 && start)
                s.getChilds(s.getEnd().getCrosspoint(), v1);
            // v1.remove(this);
            for (int j = 0; j < v1.size(); j++) {
                final Sector s1 = v1.get(j);
                if (!equals(s1)) {
                    final Stream stream = s1.getStream();
                    if (stream != null) {
                        final Row[] rs = stream.getAdded();
                        rows = RowFactory.removeRows(rows, rs);
                        final Row[] add = RowFactory.removeRows(rs, ps.getAdded());
                        if (add.length > 0)
                            ps.addRows(add);
                    }
                }
            }
            if (rows.length > 0) {
                ps.removeRows(rows);
                s.removeFromParent(rows, start);
            }
        }
    }
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) NStream(com.ramussoft.pb.data.negine.NStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 18 with Row

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

the class IDLImporter method importFromIDL.

public void importFromIDL(InputStream in) throws IOException {
    Vector<Row> streams = plugin.getRecChilds(plugin.getBaseStream(), true);
    for (Row r : streams) {
        Stream stream = (Stream) r;
        if (!stream.isEmptyName()) {
            this.streams.put(stream.getName(), stream);
        }
    }
    reader = new InputStreamReader(in, encoding);
    length = reader.read(buff);
    while (true) {
        String line = readLine();
        if (line == null)
            return;
        switch(position) {
            case KIT:
                if (starts(MODELC, line)) {
                    String name = valueOf(line);
                    try {
                        base.setName(name);
                    } catch (Exception e) {
                    }
                    plugin.getBaseFunctionQualifier().setName(name);
                    plugin.getEngine().updateQualifier(plugin.getBaseFunctionQualifier());
                    loadFonts(line);
                } else if (starts(PROJECT_NAME, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectName(name);
                } else if (starts(AUTHOR, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectAutor(name);
                } else if (starts(DIAGRAM_GRAPHICC, line)) {
                    position = DIAGRAM_GRAPHIC;
                    String name = line.substring(DIAGRAM_GRAPHICC.length() + 1);
                    Function f = getFunction(name);
                    functions.add(f);
                    boxes.clear();
                    segments.clear();
                }
                break;
            case DIAGRAM_GRAPHIC:
                if (starts(TITLE, line)) {
                    String name = valueOf(line);
                    try {
                        getFunction().setName(name);
                    } catch (Exception e) {
                    }
                } else if (starts(STATUS, line)) {
                    String name = line.substring(STATUS.length() + 1);
                    int typeOf = Status.typeOf(name);
                    Status status = getFunction().getStatus();
                    status.setType(typeOf);
                    if (typeOf < 0) {
                        status.setOtherName(name);
                        status.setType(Status.OTHER);
                    }
                    getFunction().setStatus(getFunction().getStatus());
                } else if (starts(BOXC, line)) {
                    box = new Box();
                    box.index = Integer.parseInt(getLastWord(line));
                    boxes.add(box);
                    position = BOX;
                } else if (starts(ENDDIAGRAM, line)) {
                    position = KIT;
                    createSegments();
                    functions.remove(functions.size() - 1);
                } else if (starts("ARROWSEG", line)) {
                    position = ARROWSEG;
                    seg = new Arrowseg();
                    seg.index = Integer.parseInt(line.substring("ARROWSEG".length() + 1));
                    segments.add(seg);
                }
                break;
            case BOX:
                if (starts(NAME, line)) {
                    String name = valueOf(line);
                    box.name = name;
                } else if (starts(BOX_COORDINATES, line)) {
                    box.coordinates = line.substring(BOX_COORDINATES.length() + 1);
                } else if (starts(DETAIL_REFERENCE, line)) {
                    box.reference = line.substring(DETAIL_REFERENCE.length() + 1);
                } else if (starts(ENDBOX, line)) {
                    addBox();
                    position = DIAGRAM_GRAPHIC;
                }
                break;
            case ARROWSEG:
                if (starts(SOURCE, line)) {
                    seg.source = line.substring(SOURCE.length() + 1);
                } else if (starts(PATH, line)) {
                    seg.path = line.substring(PATH.length() + 1);
                } else if (starts(LABAL_COORDINATES, line)) {
                    seg.coordinates = line.substring(LABAL_COORDINATES.length() + 1);
                } else if (starts(LABEL, line)) {
                    seg.label = valueOf(line);
                } else if (starts(SQUIGGLE_COORDINATES, line)) {
                    seg.squiggleCoordinates = line.substring(SQUIGGLE_COORDINATES.length() + 1);
                } else if (starts(SINK, line)) {
                    seg.sink = line.substring(SINK.length() + 1);
                } else if (starts("ENDSEG", line)) {
                    position = DIAGRAM_GRAPHIC;
                }
                break;
        }
    }
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) InputStreamReader(java.io.InputStreamReader) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row) IOException(java.io.IOException)

Example 19 with Row

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

the class NDataPlugin method getRowSet.

public RowSet getRowSet(final long id) {
    RowSet res = rowSets.get(id);
    if (res == null) {
        final Qualifier qualifier = engine.getQualifier(id);
        boolean create = true;
        if (IDEF0Plugin.isFunction(qualifier)) {
            create = false;
            List<Attribute> list = new ArrayList<Attribute>(qualifier.getSystemAttributes());
            list.addAll(qualifier.getAttributes());
            final Qualifier baseFunctions = IDEF0Plugin.getBaseFunctions(engine);
            res = new RowSet(engine, qualifier, list.toArray(new Attribute[list.size()]), new RowSet.RowCreater() {

                @Override
                public com.ramussoft.database.common.Row createRow(Element element, RowSet data, Attribute[] attributes, Object[] objects) {
                    if (element != null)
                        return new NFunction(NDataPlugin.this, element, data, attributes, objects) {

                            @Override
                            public long getQualifierId() {
                                if (id == baseFunctions.getId()) {
                                    return IDEF0Plugin.getBaseQualifierId(engine, getElement());
                                }
                                return id;
                            }
                        };
                    return new NFunction(NDataPlugin.this, IDEF0Plugin.findElementForBaseFunction(id, engine), data, attributes, objects) {

                        @Override
                        public String getName() {
                            return qualifier.getName();
                        }

                        @Override
                        public boolean isBase() {
                            return true;
                        }

                        @Override
                        public boolean isElement() {
                            return false;
                        }

                        @Override
                        public long getQualifierId() {
                            return id;
                        }
                    };
                }
            }) {

                @Override
                protected boolean filter(Element element) {
                    return false;
                }
            };
        }
        if (create)
            res = new RowSet(engine, qualifier, qualifier.getAttributes().toArray(new Attribute[qualifier.getAttributes().size()]), new RowSet.RowCreater() {

                @Override
                public com.ramussoft.database.common.Row createRow(Element element, RowSet data, Attribute[] attributes, Object[] objects) {
                    NRow row = new NRow(NDataPlugin.this, element, data, attributes, objects);
                    row.setElement(true);
                    return row;
                }
            });
        rowSets.put(id, res);
    }
    return res;
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 20 with Row

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

the class NDataPlugin method createRow.

public Row createRow(final Row parent, boolean element, final GlobalId globalId) {
    assert parent == null && !element || parent != null;
    if (parent instanceof Stream) {
        return (Row) streamsRowSet.createRow(baseStream);
    }
    if (parent instanceof Function)
        throw new RuntimeException("Method can not be called to create functions!");
    Row res;
    if (!element) {
        res = (Row) qualifiers.createRow((com.ramussoft.database.common.Row) parent);
    } else {
        com.ramussoft.database.common.Row row = qualifiers.findRow(((com.ramussoft.database.common.Row) parent).getElementId());
        if (row != null) {
            long qId = (Long) engine.getAttribute(row.getElement(), qualifierId);
            RowSet rowSet = getRowSet(qId);
            res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
        } else {
            RowSet rowSet = findRowSetByRowId(((com.ramussoft.database.common.Row) parent).getElementId());
            res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
        }
    }
    return res;
}
Also used : Function(com.ramussoft.pb.Function) RowSet(com.ramussoft.database.common.RowSet) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) 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