use of org.obeonetwork.dsl.entity.Entity in project InformationSystem by ObeoNetwork.
the class EntityEntityPropertiesEditionComponent 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 Entity entity = (Entity) elt;
final EntityPropertiesEditionPart entityPart = (EntityPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EntityViewsRepository.Entity_.Properties.name))
entityPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, entity.getName()));
if (isAccessible(EntityViewsRepository.Entity_.Properties.superType)) {
// init part
superTypeSettings = new EObjectFlatComboSettings(entity, EnvironmentPackage.eINSTANCE.getStructuredType_Supertype());
entityPart.initSuperType(superTypeSettings);
// set the button mode
entityPart.setSuperTypeButtonMode(ButtonsModeEnum.BROWSE);
}
if (isAccessible(EntityViewsRepository.Entity_.Properties.description))
entityPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, entity.getDescription()));
if (isAccessible(EntityViewsRepository.Entity_.Properties.associatedTypes)) {
associatedTypesSettings = new ReferencesTableSettings(entity, EnvironmentPackage.eINSTANCE.getStructuredType_AssociatedTypes());
entityPart.initAssociatedTypes(associatedTypesSettings);
}
if (isAccessible(EntityViewsRepository.Entity_.Properties.associatedTypes)) {
entityPart.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);
}
use of org.obeonetwork.dsl.entity.Entity in project InformationSystem by ObeoNetwork.
the class EntityPersistencePropertiesEditionComponent 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 Entity entity = (Entity) elt;
final PersistencePropertiesEditionPart persistencePart = (PersistencePropertiesEditionPart) editingPart;
// init values
if (isAccessible(EntityViewsRepository.Persistence.Properties.estimatedVolumetry)) {
persistencePart.setEstimatedVolumetry(EEFConverterUtil.convertToString(EcorePackage.Literals.EINT, entity.getEstimatedVolumetry()));
}
if (isAccessible(EntityViewsRepository.Persistence.Properties.estimatedAccess)) {
persistencePart.setEstimatedAccess(EEFConverterUtil.convertToString(EcorePackage.Literals.EINT, entity.getEstimatedAccess()));
}
if (isAccessible(EntityViewsRepository.Persistence.Properties.historized)) {
persistencePart.setHistorized(entity.isHistorized());
}
if (isAccessible(EntityViewsRepository.Persistence.Properties.inheritanceKind)) {
persistencePart.initInheritanceKind(EEFUtils.choiceOfValues(entity, EntityPackage.eINSTANCE.getEntity_InheritanceKind()), entity.getInheritanceKind());
}
// init filters
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.entity.Entity in project InformationSystem by ObeoNetwork.
the class EntityToMLD method processNamespaceAndCreateAdditionalFields.
private void processNamespaceAndCreateAdditionalFields(Namespace namespace) {
// create tables
for (Entity entity : EntityUtils.getEntitiesInNamespace(namespace)) {
// Create technical fields
Table table = getFromOutputTraceabilityMap(entity, DatabasePackage.Literals.TABLE);
createAdditionalFields(table);
}
// process sub-namespaces
for (Namespace subnamespace : namespace.getOwnedNamespaces()) {
processNamespaceAndCreateAdditionalFields(subnamespace);
}
}
use of org.obeonetwork.dsl.entity.Entity in project InformationSystem by ObeoNetwork.
the class EntityToMLD method handleForeignKey.
private void handleForeignKey(Reference reference) {
Table targetTable = getFromOutputTraceabilityMap(EntityUtils.getContainingEntity(reference), DatabasePackage.Literals.TABLE);
Entity targetEntity = EntityUtils.getReferencedEntity(reference);
if (targetEntity == null) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "No entity referenced by " + EntityUtils.getContainingEntity(reference).getName() + "." + reference.getName()));
return;
}
Table sourceTable = getFromOutputTraceabilityMap(targetEntity, DatabasePackage.Literals.TABLE);
if (sourceTable == null) {
// Table was not found among the newly created tables
// try to retrieve it from additional resources
String targetEntityKey = LabelProvider.getTableKeyForEntity(targetEntity);
EObject targetObject = getAdditionalResourcesMap().get(targetEntityKey);
if (targetObject instanceof Table) {
sourceTable = (Table) targetObject;
} else {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot resolve table: " + targetEntityKey + " for Reference!"));
return;
}
}
if (shouldCreateJoinTable(reference)) {
createJoinTable(reference, sourceTable, targetTable);
} else {
boolean nullable = getNullableValueForFK(reference);
if (shouldCreateFKInSource(reference)) {
createForeignKey(reference, targetTable, sourceTable, nullable);
} else if (shouldCreateFKInTarget(reference)) {
createForeignKey(reference, sourceTable, targetTable, nullable);
}
}
}
use of org.obeonetwork.dsl.entity.Entity in project InformationSystem by ObeoNetwork.
the class MLDToEntity method createEntity.
private void createEntity(Table table) {
Entity entity = getFromInputTraceabilityMap(table, EntityPackage.Literals.ENTITY);
if (entity == null) {
// The entity does not already exist
// We have to create a new one
entity = EntityFactory.eINSTANCE.createEntity();
getTargetNamespace(table.getOwner()).getTypes().add(entity);
entity.setName(LabelProvider.getEntityNameFromTable(table));
}
// Add to new traceability map
addToOutputTraceability(table, entity);
// The following properties are modified even if they already existed
AnnotationHelper.setPhysicalNameAnnotation(entity, LabelProvider.getEntityPhysicalNameFromTable(table));
entity.setDescription(table.getComments());
AnnotationHelper.removePhysicalUniqueAnnotations(entity);
for (Column column : table.getColumns()) {
if (!column.isInForeignKey() && !column.isInPrimaryKey() && !AdditionalFieldsUtils.isAdditionalColumn(column)) {
createAttribute(column, entity);
}
}
AnnotationHelper.removePhysicalCheckAnnotations(entity);
List<Constraint> constraintsToCreate = new ArrayList<Constraint>();
for (Constraint constraint : table.getConstraints()) {
if (!AdditionalFieldsUtils.isAdditionalConstraint(constraint)) {
constraintsToCreate.add(constraint);
}
}
AnnotationHelper.setAllConstraints(entity, constraintsToCreate);
}
Aggregations