use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.
the class PropertiesServices method getAttrTypeFromString.
public DataType getAttrTypeFromString(Attribute attribute, String inputString) {
int delimiter = inputString.indexOf(":");
if (delimiter != -1 && delimiter < inputString.length()) {
int startMulti = inputString.indexOf("[");
String typeName;
if (startMulti != -1) {
typeName = inputString.substring(delimiter + 1, startMulti);
} else {
typeName = inputString.substring(delimiter + 1);
}
DataType dataType = getDataType(attribute, typeName);
if (dataType != null) {
return dataType;
}
}
return attribute.getType();
}
use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.
the class PropertiesServices method getDataType.
private DataType getDataType(EObject context, String name) {
String searchedName = name.trim();
Collection<Resource> semanticResources = ModelServices.getAllResources(context);
for (Resource semanticResource : semanticResources) {
TreeIterator<?> iterator = semanticResource.getAllContents();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof DataType) {
DataType type = (DataType) o;
if (searchedName.equalsIgnoreCase(type.getName())) {
return type;
}
}
}
}
return null;
}
use of org.obeonetwork.dsl.environment.DataType 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.DataType 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;
}
Aggregations