use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class TableAttributeViewer method printAttribute.
@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
Engine engine = dataPlugin.getEngine();
List<Element> list = StandardAttributesPlugin.getTableElements(engine, attribute, element);
Qualifier qualifier = StandardAttributesPlugin.getTableQualifierForAttribute(engine, attribute);
if (list.size() > 0) {
callback.beforePrint(printStream);
printStream.println("<br>");
printStream.println("<table border=1><tr>");
List<Attribute> add = new ArrayList<Attribute>();
List<TableGroupablePropertyPersistent> l = (List) engine.getAttribute(null, attribute);
for (Attribute attr : qualifier.getAttributes()) if (add.indexOf(attr) < 0) {
String name = attr.getName();
int colspan = 1;
int rowspan = 2;
for (TableGroupablePropertyPersistent p : l) {
if ((p.getOtherAttribute() == attr.getId()) && (p.getName() != null) && (p.getName().length() > 0)) {
name = p.getName();
rowspan = 1;
colspan = 0;
for (Attribute a1 : qualifier.getAttributes()) for (TableGroupablePropertyPersistent p1 : l) {
if ((name.equals(p1.getName())) && (p1.getOtherAttribute() == a1.getId())) {
colspan++;
add.add(a1);
}
}
}
}
printStream.print("<td align=\"center\" rowspan=\"" + rowspan + "\" colspan=\"" + colspan + "\"><b>" + name + "</b></td>");
}
printStream.println("</tr>");
printStream.println("<tr>");
for (Attribute a : add) {
printStream.print("<td align=\"center\"><b>" + a.getName() + "</b></td>");
}
printStream.println("</tr>");
AttributeViewerFactory factory = AttributeViewerFactory.getAttributeViewverFactory();
for (Element element2 : list) {
printStream.println("<tr>");
for (Attribute attribute2 : qualifier.getAttributes()) {
printStream.print("<td>");
AttributeViewer viewer = factory.getAttributeViewer(attribute2);
if (viewer != null) {
EmptyAttributeViewerCallback callback2 = new EmptyAttributeViewerCallback();
viewer.printAttribute(printStream, dataPlugin, element2, attribute2, parser, callback2);
if (!callback2.isBefore())
printStream.print("<center>-</center>");
} else
printStream.print("<center>-</center>");
printStream.println("</td>");
}
printStream.println("</tr>");
}
printStream.println("</table>");
callback.afterPrint(printStream);
}
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class IDEF0FunctionFilter method load.
@Override
public boolean load(Element element, RowSet rowSet) {
Engine engine = rowSet.getEngine();
Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
if (rowSet.getQualifier().getSystemAttributes().contains(attribute)) {
Integer type = (Integer) engine.getAttribute(element, attribute);
if (type != null)
return type < 1001;
}
return true;
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class HTTPParser method printClasificator.
private void printClasificator() throws IOException {
final Row row = loadRowById();
if (row == null) {
printError(RES.getString("cantLoatClasificator"));
return;
}
if (row instanceof Function) {
htmlTitle = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) row) + " " + row.getName();
} else
htmlTitle = row.getKod() + ". " + row.getName();
printStartD();
printRowBase(row);
if (row instanceof Function) {
boolean b = true;
if (!row.isLeaf()) {
b = false;
htmlStream.println("<br>");
printStartATeg("idef0/index.html?id=" + row.getGlobalId().toString());
htmlStream.print(RES.getString("idef0Model"));
printEndATeg();
}
if (row.isElement()) {
if (b)
htmlStream.println("<br>");
else
htmlStream.print(" ");
printStartATeg("idef0/index.html?id=" + row.getParentRow().getGlobalId().toString());
htmlStream.print(RES.getString("ParentIDEF0Model"));
printEndATeg();
}
htmlStream.println("<br>");
} else if (row instanceof Stream && !dataPlugin.getBaseStream().equals(row)) {
printStreamsRows((Stream) row);
}
boolean haveTable = false;
Vector<Row> v = dataPlugin.getChilds(row, row.isElement());
if (v.size() > 0) {
if (haveTable)
htmlStream.println("<br>");
printElements(RES.getString("childElements"), v.toArray(), row.isElement() ? "rows" : "clasificators");
haveTable = true;
}
if (!row.isElement()) {
if (haveTable)
htmlStream.println("<br>");
v = dataPlugin.getRecChilds(row, true);
htmlStream.println("<hr>");
String var = params.get("var");
String attr = params.get("attr");
if (var != null) {
Engine engine = dataPlugin.getEngine();
long attrId = Long.parseLong(attr);
long varId = Long.parseLong(var);
Attribute attribute = engine.getAttribute(attrId);
List<VariantPropertyPersistent> list = (List<VariantPropertyPersistent>) engine.getAttribute(null, attribute);
VariantPropertyPersistent vpp = null;
for (VariantPropertyPersistent vp : list) if (vp.getVariantId() == varId) {
vpp = vp;
break;
}
if ((vpp != null) && (vpp.getValue() != null)) {
String value = vpp.getValue();
ArrayList list1 = new ArrayList();
for (Row r : v) {
if (value.equals(((NRow) r).getAttribute(attribute)))
list1.add(r);
}
htmlStream.println("(" + value + ")");
htmlStream.println("<br>");
printElements(RES.getString("childElements"), list1.toArray(), row.isElement() ? "rows" : "clasificators");
}
} else
printElements(RES.getString("clasificatorElements"), v.toArray());
} else
printRowAttributes(row);
if (row instanceof Function && (row.isElement())) {
printFunctionsArrows((Function) row);
} else if (!(row instanceof Stream)) {
printArrowFunctionss(row);
}
printEndD();
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class HTTPParser method getReportHTMLText.
protected Source getReportHTMLText(Engine engine, Element report, Query query) {
String page = null;
try {
HashMap<String, Object> map = new HashMap<String, Object>();
ReportQuery impl;
if (dataPlugin.getEngine().getDeligate() instanceof IEngineImpl)
impl = new ReportQueryImpl(engine) {
@Override
protected Out createOut(OutputStream stream) {
try {
return new Out(stream) {
@Override
public void print(Object object) {
if (!printVersion) {
if (object instanceof Qualifier) {
Engine engine = dataPlugin.getEngine();
Element element = StandardAttributesPlugin.getElement(engine, ((Qualifier) object).getId());
if (element == null) {
print(object.toString());
} else {
String href = "rows/index.html?id=" + element.getId();
print(getStartATeg(href, false, true));
print(object.toString());
print(getEndATeg());
}
} else if (object instanceof Code) {
String href = "rows/index.html?id=" + ((Code) object).getElement().getId();
print(getStartATeg(href, false, true));
print(object.toString());
print(getEndATeg());
} else if (object instanceof com.ramussoft.database.common.Row) {
String href = "rows/index.html?id=" + ((com.ramussoft.database.common.Row) object).getElementId();
print(getStartATeg(href, false, true));
print(object.toString());
print(getEndATeg());
} else
super.print(object);
} else
super.print(object);
}
};
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
};
else
impl = (ReportQuery) dataPlugin.getEngine();
if (query != null)
map.put("query", query);
page = impl.getHTMLReport(report, map);
} catch (Exception e1) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
java.io.PrintStream s = null;
try {
s = new java.io.PrintStream(stream, true, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (e1 instanceof DataException)
s.println(((DataException) e1).getMessage(new MessageFormatter() {
@Override
public String getString(String key, Object[] arguments) {
return MessageFormat.format(ReportResourceManager.getString(key), arguments);
}
}));
else {
s.println("<pre>");
e1.printStackTrace(s);
s.println("</pre>");
}
s.flush();
try {
page = new String(stream.toByteArray(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
htmlStream.println(page);
return null;
}
if (!printVersion) {
htmlStream.println("<H4>" + report.getName() + "</H4>");
}
Source source = new Source(page);
source.fullSequentialParse();
htmlStream.println(source);
return source;
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class SimpleAttributeViewer method printAttribute.
@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
Engine engine = dataPlugin.getEngine();
Object object = engine.getAttribute(element, attribute);
if (object != null) {
callback.beforePrint(printStream);
printObject(printStream, object);
callback.afterPrint(printStream);
}
}
Aggregations