public static String getJsonFieldName(EStructuralFeature feature) { String key = EcoreUtil.getAnnotation(feature, JSON_METADATA_ANN_URI, JSON_KEY); if (key == null) { key = feature.getName(); } StringBuilder keyBuilder = new StringBuilder(); String keyType = EcoreUtil.getAnnotation(feature, JSON_METADATA_ANN_URI, JSON_KEY_TYPE); if (keyType != null) { if (keyType.equals(JSON_KEYTYPE_COMMAND)) { keyBuilder.append('.'); } else if (keyType.equals(JSON_KEYTYPE_SIGNAL)) { keyBuilder.append('+'); } else if (keyType.equals(JSON_KEYTYPE_HEADER)) { keyBuilder.append('_'); } } keyBuilder.append(key); return keyBuilder.toString(); }
/** * Set UAM annotation for any modelElement */ public static String getAnnotation(final EModelElement modelElement, final String key) { return EcoreUtil.getAnnotation(modelElement, UamPackage.eNS_URI, key); }
private String getCategoryString(EModelElement modelElement) { String result = EcoreUtil.getAnnotation(modelElement, UamPackage.eNS_URI, ICategoryConstant.CATEGORY); if (result == null) { return ""; } return result; }
/** * Queries whether an {@code epackage} has generated initializers for its classes. * * @param epackage * an epackage * * @return whether it has generated initializers */ public static boolean hasInitializers(EPackage epackage) { return EcoreUtil.getAnnotation(epackage, INITIALIZERS_ANNOTATION_SOURCE, INITIALIZERS_ANNOTATION_DETAIL) != null; }
public boolean hasCategory(EModelElement modelElement) { String result = EcoreUtil.getAnnotation(modelElement, UamPackage.eNS_URI, ICategoryConstant.CATEGORY); return (result != null); }
/** * @return A non-empty string or <code>null</code>. */ public String getValue(EModelElement element) { String value = EcoreUtil.getAnnotation(element, SOURCE_URI, keyword); if (value != null && value.length() == 0) { return null; } return value; }
public static String getName(ENamedElement eNamedElement) { String result = EcoreUtil.getAnnotation(eNamedElement, ExtendedMetaData.ANNOTATION_URI, "name"); if (result != null) { return result; } return eNamedElement.getName(); }
private String getName(ENamedElement eNamedElement) { String result = EcoreUtil.getAnnotation(eNamedElement, ExtendedMetaData.ANNOTATION_URI, "name"); if (result != null) { return result; } return eNamedElement.getName(); }
private static PObject findPObject(final SecurityModel model, final String classname) { final Collection<PObject> allPObjects = EcoreUtil.getObjectsByType(model.getEClassifiers(), UamPackage.eINSTANCE.getPObject()); for (final PObject object : allPObjects) { final String className = EcoreUtil.getAnnotation(object, UamPackage.eNS_URI, "#class_name"); //$NON-NLS-1$ if (classname.equals(className)) { return object; } } return null; }
public String getSchemaLocation() { String schemaLocation = EcoreUtil.getAnnotation(getEcorePackage(), EcorePackage.eNS_URI, "schemaLocation"); return schemaLocation == null ? "eNS_URI" : Literals.toStringLiteral(schemaLocation, getGenModel()); }
public boolean isInvariant() { String invariantValue = EcoreUtil.getAnnotation(getEcoreOperation(), EcorePackage.eNS_URI, "invariant"); if (invariantValue != null) { return "true".equals(invariantValue); } else { return "boolean".equals(getReturnType()) && getGenParameters().size() == 2 && "org.eclipse.emf.common.util.DiagnosticChain".equals ((getGenParameters().get(0)).getEcoreParameter().getEType().getInstanceClassName()) && "java.util.Map".equals ((getGenParameters().get(1)).getEcoreParameter().getEType().getInstanceClassName()); } }
public String getValidationDelegate(String constraint) { for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage())) { String expression = EcoreUtil.getAnnotation(getEcoreClassifier(), validationDelegate, constraint); if (expression != null) { return validationDelegate; } } return null; }
protected String getConstraintExpression(String constraint) { for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage())) { String expression = EcoreUtil.getAnnotation(getEcoreClassifier(), validationDelegate, constraint); if (expression != null) { return expression; } } return null; }
protected String getInvariantExpression() { for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage())) { String expression = EcoreUtil.getAnnotation(getEcoreOperation(), validationDelegate, "body"); if (expression != null) { return expression; } } return null; }
public String getValidationDelegate() { for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage())) { String expression = EcoreUtil.getAnnotation(getEcoreOperation(), validationDelegate, "body"); if (expression != null) { return validationDelegate; } } return null; }
private static IElementDescription makeDescription(final SecurityModel model) { final ElementDescription description = new ElementDescription(); description.setId(model.getId()); description.setName(model.getName()); EcoreUtil.getAnnotation(model, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR); return description; }
private static ElementDescription createElementDescription(final EModelElement permission) { final ElementDescription ed = new ElementDescription(); final String description = EcoreUtil.getAnnotation(permission, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR); ed.setDescription(description); ed.setId(((UamElement) permission).getId()); ed.setName(((ENamedElement) permission).getName()); return ed; }
public static RoleMetaInfo loadRole(final String modelId, final Role role) { final RoleMetaInfo roleMetaInfo = new RoleMetaInfo(); roleMetaInfo.setId(role.getId()); roleMetaInfo.setModelId(modelId); final String annotation = EcoreUtil.getAnnotation(role, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR); roleMetaInfo.setDescription(annotation); roleMetaInfo.setName(role.getName()); return roleMetaInfo; } }
protected static void createMetaAttribute(final BaseObjectMetaInfo poMeta, final EAttribute attribute) { final AttributeMetaInfo am = new AttributeMetaInfo(); am.setId(attribute.getName()); final String description = EcoreUtil.getAnnotation(attribute, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR); am.setDescription(description); am.setName(attribute.getName()); am.setType(attribute.getEAttributeType().getClassifierID()); am.setDefaultValue(attribute.getDefaultValueLiteral()); final String type = attribute.getEAttributeType().getInstanceClassName(); am.setTypeDescription(type.substring(type.lastIndexOf('.') + 1)); poMeta.addAttribute(am); }
private static void createMetaOperation(final PObjectMetaInfo poMeta, final POperation op, final boolean withPermissions) { final OperationMetaInfo om = new OperationMetaInfo(); final String description = EcoreUtil.getAnnotation(op, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR); om.setDescription(description); om.setId(op.getId()); om.setName(op.getName()); poMeta.addOperation(om); if (withPermissions) { for (final Object permission : op.getPermission()) { final ElementDescription ed = createElementDescription((Permission) permission); om.addPermission(ed); } } om.setObject(poMeta); }