use of com.ramussoft.common.event.QualifierAdapter in project ramus by Vitaliy-Yakovchuk.
the class AutochangePlugin method init.
@Override
public void init(final Engine engine, AccessRules accessor) {
super.init(engine, accessor);
engine.addQualifierListener(new QualifierAdapter() {
@Override
public void qualifierCreated(QualifierEvent event) {
if (event.isJournaled())
return;
if (StandardAttributesPlugin.isDisableAutoupdate(engine))
return;
Qualifier qualifier = event.getNewQualifier();
if (!qualifier.isSystem()) {
Properties ps = engine.getProperties(AUTO_ADD_ATTRIBUTES);
String ids = ps.getProperty(AUTO_ADD_ATTRIBUTE_IDS);
String attributeForName = ps.getProperty(ATTRIBUTE_FOR_NAME);
if (ids == null)
ids = "";
StringTokenizer st = new StringTokenizer(ids, " ,");
boolean added = false;
while (st.hasMoreElements()) {
String s = st.nextToken();
long id = Long.parseLong(s);
Attribute attr = engine.getAttribute(id);
if (attr != null) {
added = true;
qualifier.getAttributes().add(attr);
if (s.equals(attributeForName))
qualifier.setAttributeForName(attr.getId());
}
}
if (added) {
engine.updateQualifier(qualifier);
}
}
}
});
}
use of com.ramussoft.common.event.QualifierAdapter in project ramus by Vitaliy-Yakovchuk.
the class HierarchicalPlugin method init.
@Override
public void init(final Engine engine, AccessRules accessor) {
super.init(engine, accessor);
hierarhicalAttribute = engine.getSystemAttribute(HIERARHICAL_ATTRIBUTE);
if (hierarhicalAttribute == null) {
hierarhicalAttribute = engine.createSystemAttribute(new AttributeType(getName(), getTypeName(), true));
hierarhicalAttribute.setName(HIERARHICAL_ATTRIBUTE);
engine.updateAttribute(hierarhicalAttribute);
}
engine.setPluginProperty(getName(), HIERARHICAL_ATTRIBUTE, hierarhicalAttribute);
engine.addQualifierListener(new QualifierAdapter() {
@Override
public void qualifierCreated(QualifierEvent event) {
if (event.isJournaled())
return;
if (StandardAttributesPlugin.isDisableAutoupdate(engine))
return;
Qualifier qualifier = event.getNewQualifier();
if (qualifier.isSystem())
return;
qualifier.getSystemAttributes().add(hierarhicalAttribute);
engine.updateQualifier(qualifier);
}
});
}
Aggregations