use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class AbstractSector method splitStream.
/**
* Метод призначений для розбивання потоку при розбитті сектору. Може
* повертати переданий параметр.
*
* @param stream
* @return
*/
protected Stream splitStream(final Stream stream) {
if (stream == null)
return null;
if (!stream.isEmptyName())
return stream;
final Stream res = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
res.setRows(stream.getAdded());
return res;
}
use of com.ramussoft.pb.Stream 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;
}
}
}
use of com.ramussoft.pb.Stream 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;
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class NDataPlugin method replaceParent.
private Row replaceParent(Row row, final boolean element) {
if ((!row.isElement()) && (element) && (!(row instanceof Stream)) && (!(row instanceof Function))) {
long id = (Long) ((com.ramussoft.database.common.Row) row).getAttribute(qualifierId);
RowSet rs = getRowSet(id);
row = (Row) rs.getRoot();
}
return row;
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class AbstractSector method setRows.
public void setRows(final Row[] rows) {
synchronized (dataPlugin) {
sRec = true;
if (getStream() != null) {
final Row[] dels = RowFactory.removeRows(getStream().getAdded(), rows);
if (dels.length > 0)
removeFromParent(dels);
getStream().setRows(rows);
}
final Vector<Sector> v = new Vector();
getRecParents(v);
final Sector[] sectors = toArray(v);
final Stream[] streams = getStreams(sectors);
for (final Stream element : streams) element.addRows(rows);
for (Sector s : sectors) {
if (s.getStream() == null) {
Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream.addRows(rows);
((NSector) s).setThisStream(stream);
}
}
sRec = false;
}
}
Aggregations