use of org.obeonetwork.dsl.typeslibrary.TypeInstance in project InformationSystem by ObeoNetwork.
the class ColumnServices method typeLength.
/**
* Returns the length and the precision of the type associated to the column.
* Result is like follows :
* <ul>
* <li><length> if the type has the NativeKind.LENGTH attribute</li>
* <li><length,precision> if the type has the NativeKind.LENGTH_AND_PRECISION attribute</li>
*
* @param col
* the column
* @return a description of the length of the column's type.
*/
public String typeLength(Column col) {
final String res;
Type type = col.getType();
if (type instanceof TypeInstance) {
TypeInstance instance = (TypeInstance) type;
switch(instance.getNativeType().getSpec()) {
case LENGTH:
res = instance.getLength().toString();
break;
case LENGTH_AND_PRECISION:
res = instance.getLength() + "," + instance.getPrecision();
break;
default:
res = "";
}
} else {
res = "";
}
return res;
}
use of org.obeonetwork.dsl.typeslibrary.TypeInstance in project InformationSystem by ObeoNetwork.
the class TypeInstancePropertiesEditionComponent method updateSemanticModel.
/**
* {@inheritDoc}
* @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
*/
public void updateSemanticModel(final IPropertiesEditionEvent event) {
TypeInstance typeInstance = (TypeInstance) semanticObject;
if (TypeslibraryViewsRepository.TypeInstance.Properties.type == event.getAffectedEditor()) {
typeInstance.setNativeType(!"".equals(event.getNewValue()) ? (NativeType) event.getNewValue() : null);
}
if (TypeslibraryViewsRepository.TypeInstance.Properties.TypeAttributes.length == event.getAffectedEditor()) {
typeInstance.setLength((java.lang.Integer) EEFConverterUtil.createFromString(EcorePackage.Literals.EINTEGER_OBJECT, (String) event.getNewValue()));
}
if (TypeslibraryViewsRepository.TypeInstance.Properties.TypeAttributes.precision == event.getAffectedEditor()) {
typeInstance.setPrecision((java.lang.Integer) EEFConverterUtil.createFromString(EcorePackage.Literals.EINTEGER_OBJECT, (String) event.getNewValue()));
}
if (TypeslibraryViewsRepository.TypeInstance.Properties.literals == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.SET) {
typeInstance.getLiterals().clear();
typeInstance.getLiterals().addAll(((EList) event.getNewValue()));
}
}
}
use of org.obeonetwork.dsl.typeslibrary.TypeInstance in project InformationSystem by ObeoNetwork.
the class DatabaseFactoryImpl method createColumn.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public Column createColumn() {
ColumnImpl column = new ColumnSpec();
column.setTechID(EcoreUtil.generateUUID());
TypeInstance type = TypesLibraryFactory.eINSTANCE.createTypeInstance();
column.setType(type);
return column;
}
use of org.obeonetwork.dsl.typeslibrary.TypeInstance in project InformationSystem by ObeoNetwork.
the class ColumnServicesTest method testColumnLengthLENGTH.
@Test
public void testColumnLengthLENGTH() {
Column col = (Column) EcoreUtil.create(DatabasePackage.Literals.COLUMN);
TypeInstance type = (TypeInstance) EcoreUtil.create(TypesLibraryPackage.Literals.TYPE_INSTANCE);
NativeType nType = (NativeType) EcoreUtil.create(TypesLibraryPackage.Literals.NATIVE_TYPE);
col.setType(type);
type.setNativeType(nType);
nType.setSpec(NativeTypeKind.LENGTH);
type.setLength(255);
assertEquals("255", new ColumnServices().typeLength(col));
}
use of org.obeonetwork.dsl.typeslibrary.TypeInstance in project InformationSystem by ObeoNetwork.
the class ColumnServicesTest method testColumnLengthSIMPLE.
@Test
public void testColumnLengthSIMPLE() {
Column col = (Column) EcoreUtil.create(DatabasePackage.Literals.COLUMN);
TypeInstance type = (TypeInstance) EcoreUtil.create(TypesLibraryPackage.Literals.TYPE_INSTANCE);
NativeType nType = (NativeType) EcoreUtil.create(TypesLibraryPackage.Literals.NATIVE_TYPE);
col.setType(type);
type.setNativeType(nType);
nType.setSpec(NativeTypeKind.SIMPLE);
assertEquals("", new ColumnServices().typeLength(col));
}
Aggregations