use of com.ramussoft.report.data.Row in project ramus by Vitaliy-Yakovchuk.
the class OwnersConnection method setRecOuners.
private void setRecOuners(com.ramussoft.database.common.Row root, Hashtable<Row, List<Row>> mech, List<Row> ouner) {
List<Row> o;
for (Object obj : root.getChildren()) {
Row row = (Row) obj;
o = owners.get(row);
if (o == null) {
if (ouner != null)
owners.put(row, ouner);
else {
List<Row> value = mech.get(row);
if (value != null)
owners.put(row, value);
}
}
setRecOuners(row, mech, (o == null) ? ouner : o);
}
}
use of com.ramussoft.report.data.Row in project ramus by Vitaliy-Yakovchuk.
the class RolesConnection method getRoles.
private Rows getRoles(Data data, Row row) {
List<Row> rRows = roles.get(row);
if (rRows != null && rRows.size() > 0) {
Rows rows = new Rows(rRows.get(0).getRowSet(), data, false, 1);
rows.addAll(rRows);
return rows;
}
return new Rows(null, data, false, 0);
}
use of com.ramussoft.report.data.Row in project ramus by Vitaliy-Yakovchuk.
the class RolesConnection method getConnected.
@Override
public Rows getConnected(final Data data, Row row) {
Integer type = (Integer) row.getAttribute(IDEF0Plugin.getFunctionTypeAttribute(row.getEngine()));
if (type != null && type.intValue() == 1003) {
Long id = (Long) row.getAttribute(IDEF0Plugin.getLinkAttribute(row.getEngine()));
Rows rows = new Rows(row.getRowSet(), data, false);
if (id != null) {
Row row2 = data.findRow(id);
if (row2 != null) {
List<AnyToAnyPersistent> list = (List) row2.getAttribute(IDEF0Plugin.getStreamAddedAttribute(row2.getEngine()));
for (AnyToAnyPersistent anyPersistent : list) {
Row row3 = data.findRow(anyPersistent.getOtherElement());
row3.setElementStatus(anyPersistent.getElementStatus());
rows.add(row3);
}
}
}
return rows;
}
RolesConnection connection = (RolesConnection) data.get("RolesConnection");
if (connection != null)
return connection.getRoles(data, row);
final Engine engine = data.getEngine();
ArrayList<Long> ounerQualifierIds = loadOunerIDs(engine);
roles = new Hashtable<Row, List<Row>>();
final Hashtable<Row, List<Row>> mech = new Hashtable<Row, List<Row>>();
RowMapper mapper = new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
RowSet rowSet = data.getRowSet(rs.getLong(1));
Row row = (Row) rowSet.findRow(rs.getLong(2));
RowSet ounerRowSet = data.getRowSet(rs.getLong(3));
Row role = (Row) ounerRowSet.findRow(rs.getLong(4));
if (row == null || role == null)
return null;
List<Row> rows = mech.get(row);
if (rows == null) {
rows = new ArrayList<Row>(5);
mech.put(row, rows);
}
if (!rows.contains(role))
rows.add(role);
return null;
}
};
if (ounerQualifierIds.size() > 0) {
data.getTemplate().queryWithoutResults("SELECT b.qualifier_id, function, ramus_elements.qualifier_id, ramus_elements.element_id FROM\n" + "ramus_attribute_sector_borders, ramus_attribute_other_elements, ramus_attribute_any_to_any_elements, ramus_elements, ramus_elements b\n" + "WHERE ramus_attribute_any_to_any_elements.element_id=ramus_attribute_other_elements.other_element\n" + "AND ramus_elements.element_id=ramus_attribute_any_to_any_elements.other_element\n" + "AND ramus_attribute_sector_borders.element_id = ramus_attribute_other_elements.element_id\n" + "AND function_type=1 AND ramus_attribute_sector_borders.attribute_id in\n" + "(SELECT attribute_id FROM ramus_attributes WHERE attribute_system=true AND attribute_name='F_SECTOR_BORDER_END')\n" + "AND b.element_id=function\n" + "AND ramus_elements.qualifier_id in " + toIns(ounerQualifierIds), mapper, true);
}
data.getTemplate().queryWithoutResults("SELECT (SELECT qualifier_id FROM ramus_elements WHERE element_id=ouner_id) as function_qualifier_id, " + "ouner_id AS function, " + "(SELECT qualifier_id FROM ramus_elements WHERE element_id=other_element) as ouner_qualifier_id, " + "other_element as ouner_id FROM ramus_attribute_any_to_any_elements, ramus_attribute_function_ouners " + "WHERE ramus_attribute_any_to_any_elements.element_id IN " + "(SELECT value FROM ramus_attribute_longs WHERE ramus_attribute_longs.element_id=ramus_attribute_function_ouners.element_id)", mapper, true);
data.getTemplate().queryWithoutResults("SELECT ramus_attribute_function_ouners.element_id,\n" + "(SELECT MAX(ramus_elements.qualifier_id) FROM ramus_elements WHERE ramus_elements.element_id=ramus_attribute_function_ouners.element_id),\n" + "ramus_elements.qualifier_id,\n" + " ouner_id FROM ramus_elements, ramus_attribute_function_ouners WHERE ramus_elements.element_id=ouner_id " + "AND ramus_attribute_function_ouners.ouner_id IN (SELECT element_id FROM ramus_attribute_function_types WHERE type<1001)", new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
RowSet rowSet = data.getRowSet(rs.getLong(2));
Row row = (Row) rowSet.findRow(rs.getLong(1));
RowSet ounerRowSet = data.getRowSet(rs.getLong(3));
Row ouner = (Row) ounerRowSet.findRow(rs.getLong(4));
if (ouner != null && row != null) {
List<Row> rows = roles.get(row);
if (rows == null) {
rows = new ArrayList<Row>();
roles.put(row, rows);
}
if (!rows.contains(ouner))
rows.add(ouner);
}
return null;
}
}, true);
RowSet rowSet = data.getRowSet(row.getQualifier());
setRecOuners(rowSet.getRoot(), mech, null);
data.put("RolesConnection", this);
return getRoles(data, row);
}
use of com.ramussoft.report.data.Row in project ramus by Vitaliy-Yakovchuk.
the class RolesConnection method setRecOuners.
private void setRecOuners(com.ramussoft.database.common.Row root, Hashtable<Row, List<Row>> mech, List<Row> ouner) {
List<Row> o;
for (Object obj : root.getChildren()) {
Row row = (Row) obj;
o = roles.get(row);
if (o == null) {
if (ouner != null)
roles.put(row, ouner);
else {
List<Row> value = mech.get(row);
if (value != null)
roles.put(row, value);
}
}
setRecOuners(row, mech, (o == null) ? ouner : o);
}
}
Aggregations