本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlTerm类的典型用法代码示例。如果您正苦于以下问题:Java CsdlTerm类的具体用法?Java CsdlTerm怎么用?Java CsdlTerm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CsdlTerm类属于org.apache.olingo.commons.api.edm.provider包,在下文中一共展示了CsdlTerm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的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: createTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Override
protected EdmTerm createTerm(final FullQualifiedName termName) {
try {
CsdlTerm providerTerm = provider.getTerm(termName);
if (providerTerm != null) {
return new EdmTermImpl(this, termName.getNamespace(), providerTerm);
} else if (termSchemaDefinition != null && !termSchemaDefinition.isEmpty()) {
for (CsdlSchema schema : termSchemaDefinition) {
if (schema.getNamespace().equalsIgnoreCase(termName.getNamespace())) {
List<CsdlTerm> terms = schema.getTerms();
for (CsdlTerm term : terms) {
if (term.getName().equals(termName.getName())) {
return new EdmTermImpl(this, termName.getNamespace(), term);
}
}
}
}
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
示例3: initialTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void initialTerm() {
EdmTerm term = new EdmTermImpl(mock(Edm.class), "namespace", new CsdlTerm());
assertTrue(term.isNullable());
assertNull(term.getName());
assertNull(term.getMaxLength());
assertNull(term.getPrecision());
assertNull(term.getScale());
assertNull(term.getSrid());
assertNotNull(term.getAnnotations());
assertTrue(term.getAnnotations().isEmpty());
assertNotNull(term.getFullQualifiedName());
try {
term.getType();
fail("EdmException expected");
} catch (EdmException e) {
assertEquals("Terms must hava a full qualified type.", e.getMessage());
}
}
示例4: termWithTypeDef
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void termWithTypeDef() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.TypeDef";
String name = "TypeDef";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmTypeDefinition typeMock = mock(EdmTypeDefinition.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getTypeDefinition(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例5: termWithEnumType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void termWithEnumType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Enum";
String name = "Enum";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmEnumType typeMock = mock(EdmEnumType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getEnumType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例6: termWithComplexType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void termWithComplexType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Complex";
String name = "Complex";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmComplexType typeMock = mock(EdmComplexType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getComplexType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例7: termWithEntityType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void termWithEntityType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Entity";
String name = "Entity";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmEntityType typeMock = mock(EdmEntityType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getEntityType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例8: invalidAppliesToContent
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void invalidAppliesToContent() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("Edm.String");
csdlTerm.setAppliesTo(Arrays.asList("Invalid"));
EdmTerm localTerm = new EdmTermImpl(mock(Edm.class), "namespace", csdlTerm);
try {
localTerm.getAppliesTo();
fail("Expected an EdmException");
} catch (EdmException e) {
assertEquals("Invalid AppliesTo value: Invalid", e.getMessage());
}
}
示例9: getTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Override
public CsdlTerm getTerm(final FullQualifiedName termName) throws ODataException {
if (new FullQualifiedName("ns", "term").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("term");
} else if (new FullQualifiedName("namespace", "Term1").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term1");
} else if (new FullQualifiedName("ns", "Term2").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term2")
.setNullable(false).setDefaultValue("default").setMaxLength(1).setPrecision(2).setScale(3);
} else if (new FullQualifiedName("ns", "Term3").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term3")
.setAppliesTo(Arrays.asList("Property", "EntitySet", "Schema"));
} else if (new FullQualifiedName("ns", "Term4").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term4").setBaseTerm("namespace.Term1");
} else if (new FullQualifiedName("Core", "Description").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Description");
}
return null;
}
示例10: getTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Override
public CsdlTerm getTerm(final FullQualifiedName termName) throws ODataException {
if (new FullQualifiedName("ns", "term").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("term");
} else if (new FullQualifiedName("namespace", "Term1").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term1");
} else if (new FullQualifiedName("ns", "Term2").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term2")
.setNullable(false).setDefaultValue("default").setMaxLength(1).setPrecision(2).setScale(3);
} else if (new FullQualifiedName("ns", "Term3").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term3")
.setAppliesTo(Arrays.asList("Property", "EntitySet", "Schema"));
} else if (new FullQualifiedName("ns", "Term4").equals(termName)) {
return new CsdlTerm().setType("Edm.String").setName("Term4").setBaseTerm("namespace.Term1");
}
return null;
}
示例11: getTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
/**
* Gets term by term name.
*
* @param termName
* term name
* @return found term, otherwise null
*/
public CsdlTerm getTerm(String termName) {
TermAnnotation temAnnotation = annotations.get(termName);
if (temAnnotation != null) {
return annotations.get(termName).term;
} else {
return null;
}
}
示例12: createTerms
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
protected List<EdmTerm> createTerms() {
final List<EdmTerm> edmTerms = new ArrayList<EdmTerm>();
final List<CsdlTerm> providerTerms = schema.getTerms();
if (providerTerms != null) {
for (CsdlTerm term : providerTerms) {
FullQualifiedName termName = new FullQualifiedName(namespace, term.getName());
EdmTermImpl termImpl = new EdmTermImpl(edm, getNamespace(), term);
edmTerms.add(termImpl);
edm.cacheTerm(termName, termImpl);
}
}
return edmTerms;
}
示例13: setupTypes
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Before
public void setupTypes() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("Edm.String");
when(provider.getTerm(csdlTerm1Name)).thenReturn(csdlTerm);
initialTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
CsdlTerm derivedCsdlTerm = new CsdlTerm();
FullQualifiedName derivedTermName = new FullQualifiedName("namespace", "name2");
derivedCsdlTerm.setName(derivedTermName.getName());
derivedCsdlTerm.setType("Edm.String");
derivedCsdlTerm.setBaseTerm("namespace.name1");
List<String> appliesTo = new ArrayList<String>();
appliesTo.add("Property");
derivedCsdlTerm.setAppliesTo(appliesTo);
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("name1"));
derivedCsdlTerm.setAnnotations(csdlAnnotations);
derivedCsdlTerm.setNullable(false);
derivedCsdlTerm.setMaxLength(new Integer(15));
derivedCsdlTerm.setDefaultValue("abc");
derivedCsdlTerm.setPrecision(new Integer(14));
derivedCsdlTerm.setScale(new Integer(13));
when(provider.getTerm(derivedTermName)).thenReturn(derivedCsdlTerm);
derivedTerm = new EdmTermImpl(edm, "namespace", derivedCsdlTerm);
}
示例14: invalidType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
@Test
public void invalidType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("invalid.invalid");
EdmTerm localTerm = new EdmTermImpl(mock(Edm.class), "namespace", csdlTerm);
try {
localTerm.getType();
fail("Expected an EdmException");
} catch (EdmException e) {
assertEquals("Cannot find type with name: invalid.invalid", e.getMessage());
}
}
示例15: readTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入依赖的package包/类
private CsdlTerm readTerm(XMLEventReader reader, StartElement element) throws XMLStreamException {
CsdlTerm term = new CsdlTerm();
term.setName(attr(element, "Name"));
term.setType(attr(element, "Type"));
if (attr(element, "BaseTerm") != null) {
term.setBaseTerm(attr(element, "BaseTerm"));
}
if (attr(element, "DefaultValue") != null) {
term.setDefaultValue(attr(element, "DefaultValue"));
}
if (attr(element, "AppliesTo") != null) {
String[] appliesTo = attr(element, "AppliesTo").split("\\s+");
term.setAppliesTo(Arrays.asList(appliesTo));
}
term.setNullable(Boolean.parseBoolean(attr(element, "Nullable")));
String maxLength = attr(element, "MaxLength");
if (maxLength != null) {
term.setMaxLength(Integer.parseInt(maxLength));
}
String precision = attr(element, "Precision");
if (precision != null) {
term.setPrecision(Integer.parseInt(precision));
}
String scale = attr(element, "Scale");
if (scale != null) {
term.setScale(Integer.parseInt(scale));
}
String srid = attr(element, "SRID");
if (srid != null) {
term.setSrid(SRID.valueOf(srid));
}
peekAnnotations(reader, "Term", term);
return term;
}