use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method init.
@Override
public void init(final Engine engine, AccessRules accessor) {
super.init(engine, accessor);
engine.setPluginProperty(IDEF0, PLUGIN, this);
Qualifier crosspoints = getQualifier(CROSSPOINTS);
if (crosspoints != null) {
List<Element> elements = engine.getElements(crosspoints.getId());
Attribute crosspointId = getSysteAttribute(CROSSPOINT_ID_ATTRIBUTE);
if (elements.size() > 0) {
Element element = elements.get(0);
try {
long long1 = (Long) engine.getAttribute(element, crosspointId);
while ((long1 > engine.nextValue(CROSSPOINTS_SEQUENCE))) ;
} catch (NullPointerException e) {
}
engine.deleteElement(element.getId());
}
crosspoints.getSystemAttributes().clear();
engine.updateQualifier(crosspoints);
try {
engine.deleteAttribute(crosspointId.getId());
} catch (Exception e) {
}
engine.deleteQualifier(crosspoints.getId());
}
functionAttributes.add(createAttribute(F_VISUAL_DATA, new AttributeType(IDEF0, "VisualData", false)));
functionAttributes.add(createAttribute(F_PAGE_SIZE, new AttributeType("Core", "Text", true)));
functionAttributes.add(createAttribute(F_BACKGROUND, new AttributeType(IDEF0, "Color", false)));
functionAttributes.add(createAttribute(F_FOREGROUND, new AttributeType(IDEF0, "Color", false)));
functionAttributes.add(createAttribute(F_BOUNDS, new AttributeType(IDEF0, "FRectangle", false)));
functionAttributes.add(createAttribute(F_FONT, new AttributeType(IDEF0, "Font", false)));
functionAttributes.add(createAttribute(F_STATUS, new AttributeType(IDEF0, "Status", false)));
functionAttributes.add(createAttribute(F_TYPE, new AttributeType(IDEF0, "Type", false)));
functionAttributes.add(createAttribute(F_OUNER_ID, new AttributeType(IDEF0, "OunerId", false)));
functionAttributes.add(createAttribute(F_DECOMPOSITION_TYPE, new AttributeType(IDEF0, "DecompositionType", false)));
functionAttributes.add(createAttribute(F_AUTHOR, new AttributeType("Core", "Text", true)));
functionAttributes.add(createAttribute(F_CREATE_DATE, new AttributeType("Core", "Date", false)));
functionAttributes.add(createAttribute(F_REV_DATE, new AttributeType("Core", "Date", false)));
functionAttributes.add(createAttribute(F_SYSTEM_REV_DATE, new AttributeType("Core", "Date", false)));
functionAttributes.add(createAttribute(F_LINK, new AttributeType("Core", "Long", false)));
Attribute sectorFunction = createAttribute(F_SECTOR_FUNCTION, new AttributeType("Core", "OtherElement", false));
Attribute sStream = createAttribute(F_SECTOR_STREAM, new AttributeType("Core", "OtherElement", false));
Attribute sPoints = createAttribute(F_SECTOR_POINTS, new AttributeType(IDEF0, "SectorPoint", false));
Attribute sProperties = createAttribute(F_SECTOR_PROPERTIES, new AttributeType(IDEF0, "SectorProperties", false));
Attribute sStreamName = createAttribute(F_STREAM_NAME, new AttributeType("Core", "Text", true));
Attribute aSector = createAttribute(F_SECTOR_ATTRIBUTE, new AttributeType(IDEF0, "Sector", false));
Attribute aSectorBorderStart = createAttribute(F_SECTOR_BORDER_START, new AttributeType(IDEF0, "SectorBorder", false));
Attribute aSectorBorderEnd = createAttribute(F_SECTOR_BORDER_END, new AttributeType(IDEF0, "SectorBorder", false));
Attribute aStreamAdded = createAttribute(F_STREAM_ADDED, new AttributeType(IDEF0, "AnyToAny", false));
baseFunctionQualifierId = createAttribute(F_BASE_FUNCTION_QUALIFIER_ID, new AttributeType("Core", "Long", true));
visualAttributes.add(getAttribute(engine, F_BOUNDS));
visualAttributes.add(getAttribute(engine, F_FONT));
visualAttributes.add(getAttribute(engine, F_BACKGROUND));
visualAttributes.add(getAttribute(engine, F_FOREGROUND));
Qualifier sectors = createQualifier(F_SECTORS);
if (justCreated) {
sectors.getSystemAttributes().add(aSector);
sectors.getSystemAttributes().add(aSectorBorderStart);
sectors.getSystemAttributes().add(aSectorBorderEnd);
sectors.getSystemAttributes().add(sectorFunction);
}
Qualifier streams = createQualifier(F_STREAMS);
boolean updateSectors = false;
if (justCreated) {
Attribute hierarchical = (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE);
OtherElementPropertyPersistent p = new OtherElementPropertyPersistent();
p.setQualifier(sectors.getId());
p.setQualifierAttribute(sStreamName.getId());
engine.setAttribute(null, sStream, p);
streams.getSystemAttributes().add(aStreamAdded);
streams.getSystemAttributes().add(hierarchical);
streams.getSystemAttributes().add(sStreamName);
streams.setAttributeForName(sStreamName.getId());
engine.updateQualifier(streams);
sectors.getSystemAttributes().add(0, sStream);
sectors.getSystemAttributes().add(hierarchical);
updateSectors = true;
}
if (sectors.getSystemAttributes().indexOf(sStream) != 0) {
sectors.getSystemAttributes().remove(sStream);
sectors.getSystemAttributes().add(0, sStream);
updateSectors = true;
}
if (sectors.getSystemAttributes().indexOf(sPoints) < 0) {
sectors.getSystemAttributes().add(sPoints);
sectors.getSystemAttributes().add(sProperties);
updateSectors = true;
}
if (updateSectors)
engine.updateQualifier(sectors);
projectPreferencesAttrtibute = createAttribute(F_PROJECT_PREFERENCES, new AttributeType(IDEF0, "ProjectPreferences", false));
baseFunctions = createQualifier(F_BASE_FUNCTIONS);
if (justCreated) {
baseFunctions.getSystemAttributes().add(baseFunctionQualifierId);
baseFunctions.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
engine.updateQualifier(baseFunctions);
installFunctionAttributes(baseFunctions, engine);
} else {
if (baseFunctions.getSystemAttributes().indexOf(projectPreferencesAttrtibute) < 0) {
baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
engine.updateQualifier(baseFunctions);
}
checkIDEF0Attributes(engine, baseFunctions);
}
Qualifier modelTree = createQualifier(F_MODEL_TREE);
final Attribute name = StandardAttributesPlugin.getAttributeNameAttribute(engine);
if (justCreated) {
modelTree.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
modelTree.getSystemAttributes().add(StandardAttributesPlugin.getAttributeQualifierId(engine));
modelTree.getAttributes().add(name);
modelTree.setAttributeForName(name.getId());
engine.updateQualifier(modelTree);
checkModelTree(modelTree);
}
if (!StandardAttributesPlugin.isDisableAutoupdate(engine)) {
engine.addElementAttributeListener(modelTree, new ElementAttributeListener() {
@Override
public void attributeChanged(AttributeEvent event) {
if (event.isJournaled())
return;
if (name.equals(event.getAttribute())) {
Long id = (Long) engine.getAttribute(event.getElement(), StandardAttributesPlugin.getAttributeQualifierId(engine));
if (id != null) {
Qualifier model = engine.getQualifier(id);
if (model != null) {
model.setName(String.valueOf(event.getNewValue()));
engine.updateQualifier(model);
}
}
}
}
});
}
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method installFunctionAttributes.
public static void installFunctionAttributes(Qualifier qualifier, Engine engine) {
if (isFunction(qualifier))
throw new RuntimeException("Qualifier is allready function.");
IDEF0Plugin plugin = (IDEF0Plugin) engine.getPluginProperty(IDEF0, PLUGIN);
for (Attribute a : plugin.functionAttributes) {
qualifier.getSystemAttributes().add(a);
}
engine.updateQualifier(qualifier);
Element e = engine.createElement(plugin.baseFunctions.getId());
engine.setAttribute(e, plugin.baseFunctionQualifierId, qualifier.getId());
engine.setAttribute(e, (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE), new HierarchicalPersistent());
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method createAttribute.
private Attribute createAttribute(String attributeName, AttributeType attributeType) {
Attribute attribute = getSysteAttribute(attributeName);
if (attribute != null) {
engine.setPluginProperty(getName(), attributeName, attribute);
return attribute;
}
attribute = engine.createSystemAttribute(attributeType);
attribute.setName(attributeName);
engine.updateAttribute(attribute);
engine.setPluginProperty(getName(), attributeName, attribute);
justCreated = true;
return attribute;
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method checkModelTree.
private void checkModelTree(Qualifier modelTree) {
List<Qualifier> models = new ArrayList<Qualifier>();
List<Qualifier> qList = engine.getQualifiers();
for (Qualifier qualifier : qList) {
if (IDEF0Plugin.isFunction(qualifier)) {
models.add(qualifier);
}
}
Collections.sort(models, new Comparator<Qualifier>() {
@Override
public int compare(Qualifier o1, Qualifier o2) {
return StringCollator.compare(o1.getName(), o2.getName());
}
});
Attribute attribute = StandardAttributesPlugin.getAttributeQualifierId(engine);
RowSet rowSet = new RowSet(engine, modelTree, new Attribute[] { attribute }, null, true);
for (Row row : rowSet.getAllRows()) {
for (int i = models.size() - 1; i >= 0; --i) {
Qualifier model = models.get(i);
Long id = (Long) row.getAttribute(attribute);
if (id != null && model.getId() == id.longValue()) {
models.remove(i);
break;
}
}
}
for (Qualifier model : models) {
Row row = rowSet.createRow(null);
row.setName(model.getName());
row.setAttribute(attribute, model.getId());
}
}
use of com.ramussoft.common.Attribute 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;
}
Aggregations