use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.
the class TypesServices method reconnectSourceOnInheritanceEdge.
/**
* Create an inheritance relationship using the reconnect edge to retrieve the supertype.
* Do nothing and displays an information dialog if the new inheritance would cause a cycle.
* @param newSubTypeCandidate
* @param edgeView Edge used to retrieve the super type (i.e.the edge's target node)
* @return
*/
public StructuredType reconnectSourceOnInheritanceEdge(final StructuredType newSubTypeCandidate, final StructuredType previousSubType, final DEdge edgeView) {
StructuredType superTypeCandidate = getStructuredTypeFromEdgeTarget(edgeView.getTargetNode());
if (previousSubType != null && superTypeCandidate != null) {
if (isSubtype(superTypeCandidate, newSubTypeCandidate)) {
// The new superType is already a sub-type of the subtype candidate
// setting the new inheritance relationship would lead to a cycle
// We warn the user that this is not possible
new UIServices().displayInfo(newSubTypeCandidate, "Creation of inheritance relationship not allowed !", "Creation has been cancelled.\n\n" + newSubTypeCandidate.getName() + " is already a super-type of " + superTypeCandidate.getName() + ".\n" + "The new inheritance relationship would cause a cycle which is not allowed.");
} else {
// Remove old inheritance
previousSubType.setSupertype(null);
newSubTypeCandidate.setSupertype(superTypeCandidate);
}
}
return newSubTypeCandidate;
}
use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.
the class BindingService method getAllStructuredTypes.
private Collection<StructuredType> getAllStructuredTypes(EObject any) {
// Collect all structured types
Collection<StructuredType> structuredTypes = new ArrayList<StructuredType>();
// First, get all semantic resources in session
Collection<Resource> semanticResources = getAllSemanticResourcesInSession(any);
for (Resource resource : semanticResources) {
TreeIterator<EObject> iterator = EcoreUtil.getAllContents(resource, true);
while (iterator.hasNext()) {
EObject eObject = (EObject) iterator.next();
if (eObject instanceof StructuredType) {
structuredTypes.add((StructuredType) eObject);
} else {
if (!(eObject instanceof TypesDefinition || eObject instanceof NamespacesContainer || isOverviewRootInstance(eObject))) {
iterator.prune();
}
}
}
}
return structuredTypes;
}
use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.
the class DBoundElementContentProvider method getDelegatedChildren.
private EObject[] getDelegatedChildren(EObject object) {
if (object instanceof StructuredType) {
StructuredType structuredType = (StructuredType) object;
List<Property> properties = new ArrayList<Property>();
properties.addAll(structuredType.getAttributes());
for (StructuredType associatedType : structuredType.getAssociatedTypes()) {
properties.addAll(associatedType.getAttributes());
}
properties.addAll(structuredType.getReferences());
return (EObject[]) properties.toArray(new EObject[] {});
} else if (object instanceof Reference) {
Reference entityReference = (Reference) object;
if (entityReference.getReferencedType() != null) {
return getDelegatedChildren(entityReference.getReferencedType());
} else {
return new EObject[] {};
}
}
return new EObject[] {};
}
use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.
the class EntityToMLD method createTable.
private void createTable(Entity entity) {
// Retrieve the existing table
Table table = getFromInputTraceabilityMap(entity, DatabasePackage.Literals.TABLE);
Namespace namespace = EntityUtils.getContainingNamespace(entity);
if (table == null) {
// The table does not already exist we have to create a new one
table = DatabaseFactory.eINSTANCE.createTable();
TableContainer targetTableContainer = getTargetTableContainer(namespace);
targetTableContainer.getTables().add(table);
} else {
// We have to ensure the schema name is correct
String realSchemaName = getSchemaNameFromNamespace(namespace);
TableContainer tableContainer = table.getOwner();
if (!realSchemaName.equals(tableContainer.getName())) {
tableContainer.setName(realSchemaName);
}
}
// Add to traceability map
addToOutputTraceability(entity, table);
// The following properties are modified even if they already existed
table.setName(LabelProvider.getTableNameFromEntity(entity));
table.setComments(entity.getDescription());
// Handle attributes
boolean hasPKAttribute = false;
Collection<Attribute> allAttributes = new ArrayList<Attribute>();
// Attributes from the entity and its supertypes
allAttributes.addAll(entity.getAttributes());
// Attributes from associated DTOs
for (StructuredType associatedType : entity.getAssociatedTypes()) {
allAttributes.addAll(associatedType.getAttributes());
}
for (Attribute attribute : allAttributes) {
createColumn(attribute, table);
if (attribute.isIsIdentifier()) {
hasPKAttribute = true;
}
}
// Create an ID column if no attribute was set as "primary key"
if (hasPKAttribute == false) {
createDefaultIdColumn(table);
}
// Update comments on PK
PrimaryKey primaryKey = table.getPrimaryKey();
if (primaryKey != null) {
primaryKey.setName(table.getName() + "_PK");
primaryKey.setComments(getPKComments(primaryKey));
}
// Create constraints
createConstraints(entity, table);
}
use of org.obeonetwork.dsl.environment.StructuredType in project InformationSystem by ObeoNetwork.
the class DtoDtoPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final DTO dTO = (DTO) elt;
final DtoPropertiesEditionPart dtoPart = (DtoPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.name))
dtoPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getName()));
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
// init part
supertypeSettings = new EObjectFlatComboSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_Supertype());
dtoPart.initSupertype(supertypeSettings);
// set the button mode
dtoPart.setSupertypeButtonMode(ButtonsModeEnum.BROWSE);
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.description))
dtoPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getDescription()));
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
associatedTypesSettings = new ReferencesTableSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_AssociatedTypes());
dtoPart.initAssociatedTypes(associatedTypesSettings);
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
dtoPart.addFilterToSupertype(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof StructuredType);
}
});
// Start of user code for additional businessfilters for supertype
// End of user code
}
if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
dtoPart.addFilterToAssociatedTypes(new EObjectFilter(EnvironmentPackage.Literals.STRUCTURED_TYPE));
// Start of user code for additional businessfilters for associatedTypes
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations