protected CsdlConstantExpression parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException { final CsdlConstantExpression constExpr = new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.fromString(jp.getCurrentName())); constExpr.setValue(jp.nextTextValue()); return constExpr; }
protected CsdlConstantExpression parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException { final CsdlConstantExpression constExpr = new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.fromString(jp.getCurrentName())); constExpr.setValue(jp.nextTextValue()); return constExpr; }
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); }
CsdlAnnotation xmlCharReplacement = new CsdlAnnotation(); xmlCharReplacement.setTerm("org.apache.olingo.v1.xml10-incompatible-char-replacement"); xmlCharReplacement.setExpression(new CsdlConstantExpression( ConstantExpressionType.String, invalidXmlReplacementChar)); schema.getAnnotations().add(xmlCharReplacement);
CsdlExpression expr = new CsdlConstantExpression(type, elementValue(reader, element)); write(target, expr);
CsdlExpression expr = new CsdlConstantExpression(type, elementValue(reader, element)); write(target, expr);
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); }
private <T> void readAttributeExpressions(StartElement element, T target) throws XMLStreamException { // attribute based expressions for (ConstantExpressionType type:ConstantExpressionType.values()) { if (attr(element, type.name()) != null) { write(target, new CsdlConstantExpression( type, attr(element, type.name()))); } } if (attr(element, "AnnotationPath") != null) { write(target, new CsdlAnnotationPath().setValue(attr(element, "AnnotationPath"))); } if (attr(element, "NavigationPropertyPath") != null) { write(target, new CsdlNavigationPropertyPath() .setValue(attr(element, "NavigationPropertyPath"))); } if (attr(element, "Path") != null) { write(target, new CsdlPath().setValue(attr(element, "Path"))); } if (attr(element, "PropertyPath") != null) { write(target, new CsdlPropertyPath().setValue(attr(element, "PropertyPath"))); } if (attr(element, "UrlRef") != null) { write(target, new CsdlUrlRef().setValue(new CsdlConstantExpression( ConstantExpressionType.String, attr(element, "UrlRef")))); } }
private <T> void readAttributeExpressions(StartElement element, T target) throws XMLStreamException { // attribute based expressions for (ConstantExpressionType type:ConstantExpressionType.values()) { if (attr(element, type.name()) != null) { write(target, new CsdlConstantExpression( type, attr(element, type.name()))); } } if (attr(element, "AnnotationPath") != null) { write(target, new CsdlAnnotationPath().setValue(attr(element, "AnnotationPath"))); } if (attr(element, "NavigationPropertyPath") != null) { write(target, new CsdlNavigationPropertyPath() .setValue(attr(element, "NavigationPropertyPath"))); } if (attr(element, "Path") != null) { write(target, new CsdlPath().setValue(attr(element, "Path"))); } if (attr(element, "PropertyPath") != null) { write(target, new CsdlPropertyPath().setValue(attr(element, "PropertyPath"))); } if (attr(element, "UrlRef") != null) { write(target, new CsdlUrlRef().setValue(new CsdlConstantExpression( ConstantExpressionType.String, attr(element, "UrlRef")))); } }