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);
}
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);
}
}
}
}
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;
}
}
}
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;
}
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;
}
Aggregations