use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.
the class MLDToMPD method resolveType.
@Override
protected TypeInstance resolveType(TypeInstance logicalType) {
if (logicalType.getNativeType() == null || logicalType.getNativeType().getName() == null) {
return null;
}
String physicalTypeName = getTypeProperties().getProperty(logicalType.getNativeType().getName());
NativeType physicalNativetype = findNativeType(physicalTypeName, targetTypesLibrary);
if (physicalNativetype != null) {
TypeInstance typeInstance = TypesLibraryFactory.eINSTANCE.createTypeInstance();
typeInstance.setLength(logicalType.getLength());
typeInstance.setPrecision(logicalType.getPrecision());
typeInstance.setNativeType(physicalNativetype);
return typeInstance;
}
return null;
}
use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.
the class MPDToMLD method resolveType.
@Override
protected TypeInstance resolveType(TypeInstance physicalType) {
if (physicalType.getNativeType() != null) {
NativeType logicalType = physicalType.getNativeType().getMapsTo();
if (logicalType != null) {
TypeInstance typeInstance = TypesLibraryFactory.eINSTANCE.createTypeInstance();
typeInstance.setLength(physicalType.getLength());
typeInstance.setPrecision(physicalType.getPrecision());
typeInstance.setNativeType(logicalType);
return typeInstance;
} else {
String msg = "";
EObject eContainer = physicalType.eContainer();
if (eContainer instanceof Column) {
Column column = (Column) eContainer;
msg = "[" + column.getOwner().getName() + "." + column.getName() + "] ";
}
System.err.println(msg + "Cannot resolve Logical type for : " + physicalType.getNativeType().getName());
}
} else {
System.err.println("Cannot resolve type: " + physicalType);
}
return null;
}
use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.
the class TypesLibraryUtil method findLogicalType.
public static NativeType findLogicalType(TypeInstance physicalTypeInstance) {
NativeType physicalNativeType = physicalTypeInstance.getNativeType();
NativeType logicalNativeType = physicalNativeType.getMapsTo();
if (logicalNativeType == null) {
System.err.println("Cannot map physical type: " + physicalNativeType.getName() + " to logical type");
}
return logicalNativeType;
}
use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.
the class TypeInstanceItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
TypeInstance typeInstance = (TypeInstance) object;
NativeType nativeType = typeInstance.getNativeType();
String label = null;
String length = "";
String precision = "";
if (nativeType != null) {
label = nativeType.getName();
if (label == null || label.length() == 0) {
label = "<undefined>";
}
switch(nativeType.getSpec()) {
case LENGTH:
if (typeInstance.getLength() != null) {
length = String.valueOf(typeInstance.getLength());
}
if (!label.contains("%n")) {
label = label + "(%n)";
}
label = replacePlaceholders(label, new String[] { "%n" }, new String[] { length });
break;
case LENGTH_AND_PRECISION:
if (typeInstance.getLength() != null) {
length = String.valueOf(typeInstance.getLength());
}
if (typeInstance.getPrecision() != null) {
precision = String.valueOf(typeInstance.getPrecision());
}
if (!label.contains("%n") && !label.contains("%p")) {
label = label + "(%n, %p)";
} else if (!label.contains("%n")) {
label = label + "(%n)";
} else if (!label.contains("%p")) {
label = label + "(%p)";
}
label = replacePlaceholders(label, new String[] { "%n", "%p" }, new String[] { length, precision });
break;
case ENUM:
label += "(";
for (int i = 0; i < typeInstance.getLiterals().size(); i++) {
String literal = typeInstance.getLiterals().get(i);
if (i != 0) {
label += ", ";
}
label += literal;
}
label += ")";
break;
}
} else {
label = "<undefined>";
}
return label;
}
use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.
the class SQLServerDataBaseBuilder method createTypeInstance.
@Override
protected TypeInstance createTypeInstance(NativeTypesLibrary nativeTypesLibrary, String columnType, int columnSize, int decimalDigits) {
String bkpColumnType = columnType;
if (columnSize > 0) {
columnType += "(%n";
}
if (decimalDigits > 0) {
columnType += ",%p";
}
columnType += ")";
NativeType nativeType = nativeTypesLibrary.findTypeByName(columnType);
if (nativeType == null) {
columnType = bkpColumnType;
}
return super.createTypeInstance(nativeTypesLibrary, columnType, columnSize, decimalDigits);
}
Aggregations