本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java CsdlAnnotation类的具体用法?Java CsdlAnnotation怎么用?Java CsdlAnnotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CsdlAnnotation类属于org.apache.olingo.commons.api.edm.provider包,在下文中一共展示了CsdlAnnotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTerm
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
public CsdlTerm getTerm(FullQualifiedName termName) {
if (TERM_DESCRIPTION.equals(termName)) {
return new CsdlTerm().setName("Description").setType("Edm.String")
.setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
"A brief description of a model element")),
new CsdlAnnotation().setTerm("Core.IsLanguageDependent")));
} else if (TERM_LONG_DESCRIPTION.equals(termName)) {
return new CsdlTerm().setName("LongDescription").setType("Edm.String")
.setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
"A lengthy description of a model element")),
new CsdlAnnotation().setTerm("Core.IsLanguageDependent")));
} else if (TERM_DATA.equals(termName)) {
return new CsdlTerm().setName("Data").setType("Edm.Boolean")
.setAnnotations(Arrays.asList(new CsdlAnnotation().setTerm("Core.Description").setExpression(
new CsdlConstantExpression(CsdlConstantExpression.ConstantExpressionType.String,
"Indicates if data in the TechSvc is available for the given object"))));
}
return null;
}
示例2: labeledElementWithNameAndValue
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void labeledElementWithNameAndValue() {
CsdlLabeledElement csdlLabeledElement = new CsdlLabeledElement();
csdlLabeledElement.setName("name");
csdlLabeledElement.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlLabeledElement.setAnnotations(csdlAnnotations);
EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlLabeledElement);
EdmLabeledElement asLabeled = exp.asDynamic().asLabeledElement();
assertEquals("name", asLabeled.getName());
assertNotNull(asLabeled.getValue());
assertTrue(asLabeled.getValue().isConstant());
assertNotNull(asLabeled.getAnnotations());
assertEquals(1, asLabeled.getAnnotations().size());
}
示例3: recordWithEntityTypeAndPropValues
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void recordWithEntityTypeAndPropValues() {
CsdlRecord csdlRecord = new CsdlRecord();
csdlRecord.setType("ns.et");
Edm mock = mock(Edm.class);
when(mock.getEntityType(new FullQualifiedName("ns", "et"))).thenReturn(mock(EdmEntityType.class));
List<CsdlPropertyValue> propertyValues = new ArrayList<CsdlPropertyValue>();
propertyValues.add(new CsdlPropertyValue());
csdlRecord.setPropertyValues(propertyValues);
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlRecord.setAnnotations(csdlAnnotations);
EdmExpression record = AbstractEdmExpression.getExpression(mock, csdlRecord);
EdmDynamicExpression dynExp = assertDynamic(record);
EdmRecord asRecord = dynExp.asRecord();
assertNotNull(asRecord.getPropertyValues());
assertEquals(1, asRecord.getPropertyValues().size());
assertNotNull(asRecord.getType());
assertTrue(asRecord.getType() instanceof EdmEntityType);
assertNotNull(asRecord.getAnnotations());
assertEquals(1, asRecord.getAnnotations().size());
}
示例4: withAllExpressions
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void withAllExpressions() {
CsdlIf csdlIf = new CsdlIf();
csdlIf.setGuard(new CsdlConstantExpression(ConstantExpressionType.Bool));
csdlIf.setThen(new CsdlConstantExpression(ConstantExpressionType.String));
csdlIf.setElse(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And));
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlIf.setAnnotations(csdlAnnotations);
EdmExpression exp = AbstractEdmExpression.getExpression(mock(Edm.class), csdlIf);
EdmIf asIf = exp.asDynamic().asIf();
assertNotNull(asIf.getGuard());
assertTrue(asIf.getGuard().isConstant());
assertNotNull(asIf.getThen());
assertTrue(asIf.getThen().isConstant());
assertNotNull(asIf.getElse());
assertTrue(asIf.getElse().isDynamic());
assertNotNull(asIf.getAnnotations());
assertEquals(1, asIf.getAnnotations().size());
}
示例5: propertyValue
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void propertyValue() {
CsdlPropertyValue csdlPropertyValue = new CsdlPropertyValue();
csdlPropertyValue.setProperty("property");
csdlPropertyValue.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlPropertyValue.setAnnotations(csdlAnnotations);
EdmPropertyValue asPropValue = new EdmPropertyValueImpl(mock(Edm.class), csdlPropertyValue);
assertNotNull(asPropValue.getProperty());
assertEquals("property", asPropValue.getProperty());
assertNotNull(asPropValue.getValue());
assertTrue(asPropValue.getValue().isConstant());
assertNotNull(asPropValue.getAnnotations());
assertEquals(1, asPropValue.getAnnotations().size());
}
示例6: singleAnnotation
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void singleAnnotation() {
CsdlEntityContainer annotatable = new CsdlEntityContainer();
CsdlAnnotation annotation = new CsdlAnnotation();
annotation.setTerm("namespace.name");
List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>();
annotations.add(annotation);
annotatable.setAnnotations(annotations);
EdmAnnotatable anno = new EdmAnnotatableTester(edm, annotatable);
assertNotNull(anno.getAnnotations());
assertEquals(1, anno.getAnnotations().size());
assertNotNull(anno.getAnnotation(term, null));
assertNull(anno.getAnnotation(term, "qualifier"));
}
示例7: getEnumType
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Override
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
if (nameENString.equals(enumTypeName)) {
CsdlAnnotation memberAnnotation = new CsdlAnnotation()
.setTerm("Core.Description")
.setQualifier("Target")
.setExpression(new CsdlConstantExpression(ConstantExpressionType.String, "Description of Enum Member"));
return new CsdlEnumType()
.setName(nameENString.getName())
.setFlags(true)
.setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
.setMembers(Collections.singletonList(
new CsdlEnumMember().setName("String1").setValue("1").setAnnotations(Arrays.asList(memberAnnotation))));
}
return null;
}
示例8: readAnnotations
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
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);
}
示例9: testRecord
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void testRecord() throws ODataException {
CsdlAnnotation a = annotation("Capabilities.UpdateRestrictions");
assertNotNull(a);
assertTrue(a.getExpression() instanceof CsdlRecord);
CsdlRecord expr = (CsdlRecord)a.getExpression();
assertEquals(1, expr.getPropertyValues().size());
CsdlPropertyValue value = expr.getPropertyValues().get(0);
assertEquals("NonUpdatableNavigationProperties", value.getProperty());
assertTrue(value.getValue() instanceof CsdlCollection);
assertEquals("OData.Description", expr.getAnnotations().get(0).getTerm());
assertEquals("descripiton test", expr.getAnnotations().get(0).getExpression().asConstant().getValue());
CsdlCollection collection = (CsdlCollection)value.getValue();
assertEquals(2, collection.getItems().size());
assertEquals("Category", ((CsdlNavigationPropertyPath)collection.getItems().get(1)).getValue());
}
示例10: getProperties
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
/**
* Retrieve properties for the entity type.
*
* @param index
* ES index.
* @param type
* ES type.
* @param metaData
* ES mapping metadata object.
* @return list of properties
* @throws ODataException
* OData exception
*/
protected List<CsdlProperty> getProperties(String index, String type, MappingMetaData metaData)
throws ODataException {
try {
ParsedMapWrapper esTypeProperties = new ParsedMapWrapper(metaData.sourceAsMap())
.mapValue(ElasticConstants.PROPERTIES_PROPERTY);
List<CsdlProperty> properties = new ArrayList<>();
for (String esFieldName : esTypeProperties.getMap().keySet()) {
String name = csdlMapper.esFieldToCsdlProperty(index, type, esFieldName);
ParsedMapWrapper fieldMap = esTypeProperties.mapValue(esFieldName);
String esFieldType = fieldMap.stringValue(ElasticConstants.FIELD_DATATYPE_PROPERTY);
FullQualifiedName typeFQN = ObjectMapper.NESTED_CONTENT_TYPE.equals(esFieldType)
? getNestedTypeMapper().getComplexType(index, type, name)
: primitiveTypeMapper.map(esFieldType).getFullQualifiedName();
List<CsdlAnnotation> annotations = TextFieldMapper.CONTENT_TYPE.equals(esFieldType)
? Arrays.asList(getAnnotationProvider().getAnnotation(ANALYZED_TERM_NAME))
: new ArrayList<>();
Integer precision = EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName()
.equals(typeFQN) ? DATETIME_PRECISION : null;
properties.add(new ElasticCsdlProperty().setESIndex(index).setESType(type)
.setESField(esFieldName).setName(name).setType(typeFQN)
.setAnnotations(annotations).setPrecision(precision)
.setCollection(csdlMapper.esFieldIsCollection(index, type, esFieldName)));
}
return properties;
} catch (IOException e) {
throw new ODataException("Unable to parse the mapping response from Elasticsearch.", e);
}
}
示例11: getAnnotation
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
/**
* Gets annotation by term name.
*
* @param termName
* term name
* @return found annotation, otherwise null
*/
public CsdlAnnotation getAnnotation(String termName) {
TermAnnotation temAnnotation = annotations.get(termName);
if (temAnnotation != null) {
return annotations.get(termName).annotation;
} else {
return null;
}
}
示例12: createAnnotations
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
protected List<EdmAnnotation> createAnnotations() {
final List<EdmAnnotation> edmAnnotations = new ArrayList<EdmAnnotation>();
final List<CsdlAnnotation> providerAnnotations =
schema.getAnnotations();
if (providerAnnotations != null) {
for (CsdlAnnotation annotation : providerAnnotations) {
EdmAnnotationImpl annotationImpl = new EdmAnnotationImpl(edm, annotation);
edmAnnotations.add(annotationImpl);
}
}
return edmAnnotations;
}
示例13: getAnnotations
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Override
public List<EdmAnnotation> getAnnotations() {
if (annotations == null) {
final List<EdmAnnotation> annotationsLocal = new ArrayList<EdmAnnotation>();
if (annotatable != null) {
for (CsdlAnnotation annotation : annotatable.getAnnotations()) {
annotationsLocal.add(new EdmAnnotationImpl(edm, annotation));
}
annotations = Collections.unmodifiableList(annotationsLocal);
}
}
return annotations;
}
示例14: castWithExpression
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void castWithExpression() {
CsdlCast csdlExp = new CsdlCast();
csdlExp.setMaxLength(new Integer(1));
csdlExp.setPrecision(new Integer(2));
csdlExp.setScale(new Integer(3));
csdlExp.setType("Edm.String");
csdlExp.setValue(new CsdlConstantExpression(ConstantExpressionType.String));
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlExp.setAnnotations(csdlAnnotations);
EdmExpression isOf = AbstractEdmExpression.getExpression(mock(Edm.class), csdlExp);
EdmCast asIsOf = isOf.asDynamic().asCast();
assertEquals(new Integer(1), asIsOf.getMaxLength());
assertEquals(new Integer(2), asIsOf.getPrecision());
assertEquals(new Integer(3), asIsOf.getScale());
assertNotNull(asIsOf.getType());
assertTrue(asIsOf.getType() instanceof EdmPrimitiveType);
assertNotNull(asIsOf.getValue());
assertTrue(asIsOf.getValue().isConstant());
assertNotNull(asIsOf.getAnnotations());
assertEquals(1, asIsOf.getAnnotations().size());
}
示例15: functionWithParameters
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; //导入依赖的package包/类
@Test
public void functionWithParameters() {
CsdlApply csdlApply = new CsdlApply();
csdlApply.setFunction("Function");
List<CsdlExpression> parameters = new ArrayList<CsdlExpression>();
parameters.add(new CsdlConstantExpression(ConstantExpressionType.String));
parameters.add(new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.And));
csdlApply.setParameters(parameters);
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlApply.setAnnotations(csdlAnnotations);
EdmExpression apply = AbstractEdmExpression.getExpression(mock(Edm.class), csdlApply);
EdmDynamicExpression dynExp = assertDynamic(apply);
EdmApply asApply = dynExp.asApply();
assertEquals("Function", asApply.getFunction());
assertNotNull(asApply.getParameters());
assertEquals(2, asApply.getParameters().size());
assertTrue(asApply.getParameters().get(0).isConstant());
assertTrue(asApply.getParameters().get(1).isDynamic());
assertNotNull(asApply.getAnnotations());
assertEquals(1, asApply.getAnnotations().size());
}