use of org.obeonetwork.dsl.environment.Attribute in project InformationSystem by ObeoNetwork.
the class MLDToEntity method addPhysicalUnique.
private void addPhysicalUnique(Index index) {
if (index.isUnique()) {
if (index.getElements().size() == 1) {
// Add annotation on Attribute
IndexElement indexElement = index.getElements().get(0);
String annotationValue = indexElement.isAsc() ? "ASC" : "DESC";
Attribute uniqueAttribute = getFromOutputTraceabilityMap(indexElement.getColumn(), EnvironmentPackage.Literals.ATTRIBUTE);
if (uniqueAttribute != null) {
AnnotationHelper.setPhysicalUniqueAnnotation(uniqueAttribute, annotationValue);
} else {
// We can only handle the FK situation
if (indexElement.getColumn().isInForeignKey()) {
// Search the reference corresponding to a FK
for (ForeignKey fk : indexElement.getColumn().getForeignKeys()) {
Reference reference = getFromOutputTraceabilityMap(fk, EnvironmentPackage.Literals.REFERENCE);
if (reference != null) {
AnnotationHelper.setPhysicalUniqueAnnotation(reference, annotationValue);
}
}
}
}
} else {
// Add annotation on Table
Entity entity = getFromOutputTraceabilityMap(index.getOwner(), EntityPackage.Literals.ENTITY);
// Retrieve the current value of the annotation.
String annotationValue = AnnotationHelper.getPhysicalUnique(entity);
// Construct the term corresponding to the index being considered.
String annotationTerm = "";
int i = 0;
for (IndexElement indexElement : index.getElements()) {
if (i > 0) {
annotationTerm += ",";
}
annotationTerm += indexElement.getColumn().getName() + ":";
if (indexElement.isAsc()) {
annotationTerm += "ASC";
} else {
annotationTerm += "DESC";
}
i++;
}
if (annotationValue != null && !annotationValue.isEmpty()) {
annotationValue += " | ";
} else if (annotationValue == null) {
annotationValue = "";
}
annotationValue += annotationTerm;
AnnotationHelper.setPhysicalUniqueAnnotation(entity, annotationValue);
}
}
}
use of org.obeonetwork.dsl.environment.Attribute in project InformationSystem by ObeoNetwork.
the class DesignServices method isExistingDependency.
/**
* Checks whether a dependency should be displayed between 2 namespaces
* @param source
* @param target
* @return
*/
public static boolean isExistingDependency(Namespace source, Namespace target) {
for (Type type : source.getTypes()) {
if (type instanceof StructuredType) {
StructuredType structuredType = (StructuredType) type;
// Check inheritance
StructuredType supertype = structuredType.getSupertype();
if (supertype != null && target.equals(supertype.eContainer())) {
return true;
}
// Check references
for (Reference reference : structuredType.getOwnedReferences()) {
StructuredType referencedType = reference.getReferencedType();
if (referencedType != null && target.equals(referencedType.eContainer())) {
return true;
}
}
// Check attributes
for (Attribute attribute : structuredType.getOwnedAttributes()) {
DataType datatype = attribute.getType();
if (datatype instanceof Enumeration && target.equals(datatype.eContainer())) {
return true;
}
}
}
}
return false;
}
use of org.obeonetwork.dsl.environment.Attribute in project InformationSystem by ObeoNetwork.
the class DesignServices method getNbDependencies.
/**
* Returns the number of dependencies between 2 namespaces
* @param source
* @param target
* @return
*/
public static int getNbDependencies(Namespace source, Namespace target) {
int count = 0;
for (Type type : source.getTypes()) {
if (type instanceof StructuredType) {
StructuredType structuredType = (StructuredType) type;
// Check inheritance
StructuredType supertype = structuredType.getSupertype();
if (supertype != null && target.equals(supertype.eContainer())) {
count += 1;
}
// Check references
for (Reference reference : structuredType.getOwnedReferences()) {
StructuredType referencedType = reference.getReferencedType();
if (referencedType != null && target.equals(referencedType.eContainer())) {
count += 1;
}
}
// Check attributes
for (Attribute attribute : structuredType.getOwnedAttributes()) {
DataType datatype = attribute.getType();
if (datatype instanceof Enumeration && target.equals(datatype.eContainer())) {
count += 1;
}
}
}
}
return count;
}
use of org.obeonetwork.dsl.environment.Attribute in project InformationSystem by ObeoNetwork.
the class EntityFilterImpl method getAttributeReferences.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public EList<Attribute> getAttributeReferences() {
BasicEList<Attribute> result = new UniqueEList<Attribute>() {
private static final long serialVersionUID = 971586213550724954L;
protected Object[] newData(int capacity) {
return new Attribute[capacity];
}
protected boolean useEquals() {
return false;
}
};
for (Property property : getOwnedPropertyReferences()) {
if (property instanceof Attribute) {
result.add((Attribute) property);
}
}
result.shrink();
EList<Attribute> unmodifiableResult = new EcoreEList.UnmodifiableEList.FastCompare<Attribute>(this, ExtensionUtilitiesPackage.Literals.ENTITY_FILTER__ATTRIBUTE_REFERENCES, result.size(), result.data());
return unmodifiableResult;
}
Aggregations