use of com.ramussoft.common.attribute.AttributePlugin in project ramus by Vitaliy-Yakovchuk.
the class ModelParaleler method copyAttributes.
private void copyAttributes(List<Attribute> attributes, Element source, Element destination) {
for (Attribute attribute : attributes) if ((!attribute.getAttributeType().getTypeName().equals("Hierarchical")) && (!attribute.getAttributeType().getTypeName().equals("VisualData")) && (!attribute.getAttributeType().getTypeName().equals("SectorBorder"))) {
AttributePlugin plugin = attribute.getAttributeType().getAttributePlugin(fromEngine);
if (plugin == null)
System.err.println("WARNING: Attribute plugin not found for type: " + attribute.getAttributeType());
else
plugin.copyAttribute(fromEngine, toEngine, attribute, getAttribute(attribute), source, destination, this);
}
}
use of com.ramussoft.common.attribute.AttributePlugin in project ramus by Vitaliy-Yakovchuk.
the class ModelParaleler method getAttribute.
private Attribute getAttribute(Attribute source) {
if (source == null)
return null;
Attribute res = attrHash.get(source.getId());
if (res == null) {
res = toEngine.createAttribute(source.getAttributeType());
attrHash.put(source.getId(), res);
res.setName(source.getName());
AttributePlugin plugin = source.getAttributeType().getAttributePlugin(fromEngine);
plugin.copyAttribute(fromEngine, toEngine, source, res, null, null, this);
toEngine.updateAttribute(res);
}
return res;
}
use of com.ramussoft.common.attribute.AttributePlugin in project ramus by Vitaliy-Yakovchuk.
the class StandardAttributesPlugin method isSystem.
protected boolean isSystem(AttributeType attributeType) {
PluginFactory factory = (PluginFactory) engine.getPluginProperty("Core", "PluginFactory");
if (factory == null)
return false;
AttributePlugin plugin = factory.getAttributePlugin(attributeType);
if (plugin == null) {
System.err.println("WARNING: Attribute plugin for attribute type " + attributeType + " not found");
return false;
}
return plugin.isSystem();
}
use of com.ramussoft.common.attribute.AttributePlugin in project ramus by Vitaliy-Yakovchuk.
the class FileIEngineImpl method getPluginNames.
@SuppressWarnings("unchecked")
private PluginName[] getPluginNames(List<Plugin> plugins) {
List<PluginName> data = new ArrayList<PluginName>(plugins.size());
List<AttributeType> types = template.query("SELECT attribute_type_plugin_name, attribute_type_name from " + prefix + "attributes GROUP BY attribute_type_plugin_name, attribute_type_name", new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
return new AttributeType(rs.getString(1).trim(), rs.getString(2).trim());
}
});
for (int i = 0; i < plugins.size(); i++) {
Plugin plugin = plugins.get(i);
String name = plugin.getName();
if (plugin instanceof AttributePlugin) {
AttributePlugin attributePlugin = (AttributePlugin) plugin;
AttributeType type = new AttributeType(attributePlugin.getName(), attributePlugin.getTypeName());
if (types.indexOf(type) >= 0) {
name = "Attribute." + name + "." + attributePlugin.getTypeName();
data.add(new PluginName(plugin, name));
}
} else {
data.add(new PluginName(plugin, name));
}
}
return data.toArray(new PluginName[data.size()]);
}
use of com.ramussoft.common.attribute.AttributePlugin in project ramus by Vitaliy-Yakovchuk.
the class IEngineImpl method getBinaryAttribute.
@Override
@SuppressWarnings("unchecked")
public List<Persistent>[] getBinaryAttribute(long elementId, long attributeId) {
throwExaptionIfNotCan(getAccessor().canReadElement(elementId, attributeId), "Can not get attribute.");
Attribute attribute = getAttribute(attributeId);
AttributePlugin plugin = factory.getAttributePlugin(attribute.getAttributeType());
final Class<? extends Persistent>[] classes;
if (elementId >= 0)
classes = plugin.getAttributePersistents();
else
classes = plugin.getAttributePropertyPersistents();
List<Persistent>[] lists = new List[classes.length];
for (int i = 0; i < lists.length; i++) {
final Class<? extends Persistent> clazz = classes[i];
final PersistentRow row = metadata.get(clazz);
final PersistentWrapper wrapper = wrappers.get(clazz);
ArrayList<Object> params = new ArrayList<Object>(2);
ArrayList<String> paramFields = new ArrayList<String>(2);
plugin.fillAttributeQuery(row, attributeId, elementId, params, paramFields, this);
if (elementId >= 0l && attribute.getAttributeType().getTypeName().equals("ElementList") && attribute.getAttributeType().getPluginName().equals("Core")) {
return getEListFixed(row, clazz, wrapper, paramFields, params, getActiveBranchId());
}
long branchId = 0l;
try {
branchId = getBranch(prefix + "attributes_data_metadata", new Object[] { "element_id", "attribute_id" }, new Object[] { elementId, attributeId }, getActiveBranchId());
} catch (SQLException e1) {
e1.printStackTrace();
throw new RuntimeException(e1);
}
params.add(branchId);
paramFields.add("value_branch_id");
StringBuffer sb = new StringBuffer("SELECT * FROM " + row.getTableName());
if (params.size() > 0) {
sb.append(" WHERE ");
}
boolean first = true;
for (int j = 0; j < params.size(); j++) {
if (first) {
first = false;
} else {
sb.append(" AND ");
}
sb.append(paramFields.get(j));
sb.append("=?");
}
List<Persistent> list = template.query(sb.toString(), new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
try {
Persistent persistent = clazz.newInstance();
for (PersistentField field : row.getFields()) {
wrapper.setDatabaseField(persistent, field, rs);
}
return persistent;
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
throw new RuntimeException();
}
}, params.toArray(new Object[params.size()]), true);
lists[i] = list;
}
return lists;
}
Aggregations