Commit 203344e5 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ abstract translator refinement

parent 3421a12b
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -82,6 +82,10 @@ public abstract class AbstractTranslator {
		return getTypeFor(getCleanName(name), tdlPackage.Literals.SIMPLE_DATA_INSTANCE);
	}

	protected SimpleDataInstance getEnumDataInstanceFor(String name, EnumDataType type) {
		return getContentWithName(getCleanName(name), type, tdlPackage.Literals.SIMPLE_DATA_INSTANCE);
	}

	protected StructuredDataType getStructuredDataTypeFor(String name) {
		return getTypeFor(getCleanName(name), tdlPackage.Literals.STRUCTURED_DATA_TYPE);
	}
@@ -234,13 +238,16 @@ public abstract class AbstractTranslator {
		comment.setBody(body);
	}

	protected void constrainWith(final DataType generatedType, String constraintName) {
	protected Constraint constrainWith(final DataType generatedType, String constraintName) {
		ConstraintType constraintType = getTypeFor(getCleanName(constraintName), tdlPackage.Literals.CONSTRAINT_TYPE);
		if (!generatedType.getConstraint().stream().anyMatch(a->a.getType()==constraintType)) {
			Constraint constraint = tdlFactory.eINSTANCE.createConstraint();
			constraint.setType(constraintType);
			generatedType.getConstraint().add(constraint);
			return constraint;
		}
		//TODO: return existing constraint?
		return null;
	}
	
	protected DataElementMapping addDataElementMapping(String uri, DataType dataType, String tag) {