private static void addIntAnnotation(CsdlAnnotatable recipent, String term, int value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.Int, String.valueOf(value))); recipent.getAnnotations().add(annotation); }
private static void addBooleanAnnotation(CsdlAnnotatable recipent, String term, boolean value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.Bool, String.valueOf(value))); recipent.getAnnotations().add(annotation); }
private static void addStringAnnotation(CsdlAnnotatable recipent, String term, String value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.String, value)); recipent.getAnnotations().add(annotation); }
private static void addStringCollectionAnnotation(CsdlAnnotatable recipent, String term, List<String> values) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); CsdlCollection collection = new CsdlCollection(); for (String value:values) { collection.getItems().add(new CsdlConstantExpression(ConstantExpressionType.String, value)); } annotation.setExpression(collection); recipent.getAnnotations().add(annotation); }
xmlCharReplacement.setTerm("org.apache.olingo.v1.xml10-incompatible-char-replacement"); xmlCharReplacement.setExpression(new CsdlConstantExpression( ConstantExpressionType.String, invalidXmlReplacementChar));
private void extractAnnotations(List<CsdlAnnotation> edmAnnotations, AnnotatedElement element, String internalName) throws ODataJPAModelException { final EdmAnnotation jpaAnnotation = element.getAnnotation(EdmAnnotation.class); if (jpaAnnotation != null) { CsdlAnnotation edmAnnotation = new CsdlAnnotation(); edmAnnotation.setTerm(jpaAnnotation.term()); edmAnnotation.setQualifier(jpaAnnotation.qualifier()); if (!(jpaAnnotation.constantExpression().type() == ConstantExpressionType.Int && jpaAnnotation.constantExpression().value().equals("default")) && !(jpaAnnotation.dynamicExpression().path().isEmpty())) { throw new ODataJPAModelException( ODataJPAModelException.MessageKeys.ODATA_ANNOTATION_TWO_EXPRESSIONS, internalName); } else if (jpaAnnotation.constantExpression() != null) { edmAnnotation.setExpression(new CsdlConstantExpression(jpaAnnotation.constantExpression().type(), jpaAnnotation.constantExpression().value())); } edmAnnotations.add(edmAnnotation); } }
private void readAnnotations(XMLEventReader reader, StartElement element, CsdlAnnotatable edmObject) throws XMLStreamException { if (!parseAnnotations) { return; } final CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(attr(element, "Term")); for (ConstantExpressionType type:ConstantExpressionType.values()) { if (attr(element, type.name()) != null) { annotation.setExpression(new CsdlConstantExpression( type, attr(element, type.name()))); } } readExpressions(reader, element, annotation); edmObject.getAnnotations().add(annotation); }
private void readAnnotations(XMLEventReader reader, StartElement element, CsdlAnnotatable edmObject) throws XMLStreamException { if (!parseAnnotations) { return; } final CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(attr(element, "Term")); for (ConstantExpressionType type:ConstantExpressionType.values()) { if (attr(element, type.name()) != null) { annotation.setExpression(new CsdlConstantExpression( type, attr(element, type.name()))); } } readExpressions(reader, element, annotation); edmObject.getAnnotations().add(annotation); }