use of com.avaloq.tools.ddk.xtext.export.export.Export in project dsl-devkit by dsldevkit.
the class ExportJavaValidator method checkExportFieldUniqueness.
/**
* Checks that the exports don't have overlapping features, as a feature export is inherited by the export of subtypes.
*
* @param context
* model to check
*/
@Check
public void checkExportFieldUniqueness(final ExportModel context) {
UniquenessJavaValidationHelper<Attribute> helper = new UniquenessJavaValidationHelper<Attribute>(NameFunctions.fromFeature(ExportPackage.Literals.ATTRIBUTE__ATTRIBUTE), getMessageAcceptor()) {
@Override
public String getMessage(final Attribute attribute) {
return "duplicate found: " + attribute.getAttribute().getName();
}
};
UniquenessJavaValidationHelper<UserData> helper2 = new UniquenessJavaValidationHelper<UserData>(NameFunctions.fromFeature(ExportPackage.Literals.USER_DATA__NAME), getMessageAcceptor());
for (Export export : context.getExports()) {
helper.errorOnDuplicates(export.getAttributes(), ExportPackage.Literals.ATTRIBUTE__ATTRIBUTE);
helper2.errorOnDuplicates(export.getUserData(), ExportPackage.Literals.USER_DATA__NAME);
}
}
use of com.avaloq.tools.ddk.xtext.export.export.Export in project dsl-devkit by dsldevkit.
the class ExportFragment method getGuiceBindingsRt.
/**
* {@inheritDoc}
*/
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
final BindFactory bindFactory = new BindFactory();
// $NON-NLS-1$
final String namingPrefix = GrammarUtil.getNamespace(grammar) + ".naming." + GrammarUtil.getName(grammar);
// $NON-NLS-1$
final String resourcePrefix = GrammarUtil.getNamespace(grammar) + ".resource." + GrammarUtil.getName(grammar);
ExportModel m = getModel(grammar);
if (m != null) {
// $NON-NLS-1$
bindFactory.addTypeToType(IQualifiedNameProvider.class.getName(), namingPrefix + "ExportedNamesProvider");
if (!m.getInterfaces().isEmpty()) {
// $NON-NLS-1$
bindFactory.addTypeToType(IFingerprintComputer.class.getName(), resourcePrefix + "FingerprintComputer");
}
if (!m.getExports().isEmpty()) {
// $NON-NLS-1$
bindFactory.addTypeToType(IDefaultResourceDescriptionStrategy.class.getName(), resourcePrefix + "ResourceDescriptionStrategy");
}
if (Iterables.any(m.getExports(), new Predicate<Export>() {
@Override
public boolean apply(final Export input) {
return input.isFingerprint() && input.getFragmentAttribute() != null;
}
})) {
// $NON-NLS-1$
bindFactory.addTypeToType(IFragmentProvider.class.getName(), resourcePrefix + "FragmentProvider");
}
}
// $NON-NLS-1$
bindFactory.addTypeToType(IResourceDescription.Manager.class.getName(), resourcePrefix + "ResourceDescriptionManager");
return bindFactory.getBindings();
}
use of com.avaloq.tools.ddk.xtext.export.export.Export in project dsl-devkit by dsldevkit.
the class ExportJavaValidator method checkConsistentFingerprints.
/**
* Make sure only one type of fingerprinting is used.
*
* @param context
* export model
*/
@Check
public void checkConsistentFingerprints(final ExportModel context) {
List<Export> resourceFingerprintExports = Lists.newArrayList();
List<Export> objectFingerprintExports = Lists.newArrayList();
for (Export exp : context.getExports()) {
if (exp.isResourceFingerprint()) {
resourceFingerprintExports.add(exp);
} else if (exp.isFingerprint()) {
objectFingerprintExports.add(exp);
}
}
if (!objectFingerprintExports.isEmpty() && !resourceFingerprintExports.isEmpty()) {
for (Export exp : Iterables.concat(resourceFingerprintExports, objectFingerprintExports)) {
error("Resource and object fingerprints cannot be mixed", exp, exp.isFingerprint() ? ExportPackage.Literals.EXPORT__FINGERPRINT : ExportPackage.Literals.EXPORT__RESOURCE_FINGERPRINT, null);
}
}
}
Aggregations