本文整理汇总了Java中org.odata4j.edm.EdmProperty.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java EdmProperty.Builder方法的具体用法?Java EdmProperty.Builder怎么用?Java EdmProperty.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.odata4j.edm.EdmProperty
的用法示例。
在下文中一共展示了EdmProperty.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PropertyLimitChecker
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* constructor.
* @param metadata UserDataのメタデータ(プロパティ更新前)
* @param entityTypeName 追加対象のEntityType名
* @param dynamicPropCount 追加されるDynamicProperty数
*/
public PropertyLimitChecker(final EdmDataServices metadata,
final String entityTypeName, final int dynamicPropCount) {
this();
// 引数で受け取る metadataは更新前のものなので、追加後のメタデータを作成する必要がある。
Builder builder = EdmDataServices.newBuilder(metadata);
// 追加対象数分、ダミーでプロパティをスキーマ情報に追加する
String dummyKey = "dummy" + System.currentTimeMillis();
for (int i = 0; i < dynamicPropCount; i++) {
EdmEntityType.Builder entityTypeBuilder = builder
.findEdmEntityType(UserDataODataProducer.USER_ODATA_NAMESPACE + "." + entityTypeName);
EdmProperty.Builder propertyBuilder =
EdmProperty.newBuilder(String.format("%s_%03d", dummyKey, i))
.setType(EdmSimpleType.getSimple("Edm.String"));
entityTypeBuilder.addProperties(propertyBuilder);
}
// 変更後のメタデータを作成
this.metadata = builder.build();
}
示例2: for
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private EdmComplexType.Builder ComplexTypeにcomplex型Propertyを指定数作成(int count, String complexTypeName,
EdmComplexType.Builder builder) {
// ComplexTypeを新規に作成
EdmComplexType.Builder ctBuilder = EdmComplexType.newBuilder();
ctBuilder.setName(complexTypeName).setNamespace(NS);
// ComplexTypeに加えるべき プロパティを作成
List<EdmProperty.Builder> pBuilderList = new ArrayList<EdmProperty.Builder>();
for (int i = 0; i < count; i++) {
EdmProperty.Builder pBuilder = EdmProperty.newBuilder(String.format("%s_prop_%03d", complexTypeName, i))
.setType(ctBuilder);
pBuilderList.add(pBuilder);
// 予約語プロパティ用ダミー
pBuilder = EdmProperty.newBuilder(String.format("_reservedProp_%03d", i))
.setType(EdmSimpleType.STRING);
builder.addProperties(pBuilder);
}
builder.addProperties(pBuilderList);
return ctBuilder;
}
示例3: parseLinks
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* Parses the links.
*
* @param reader the reader
* @return the iterable
*/
@SuppressWarnings("unchecked")
public static Iterable<SingleLink> parseLinks(Reader reader) {
EdmProperty.Builder ctPropBuilder = EdmProperty.newBuilder("url").setType(EdmSimpleType.STRING);
List<EdmProperty.Builder> complexTypeBuilder = new ArrayList<EdmProperty.Builder>();
complexTypeBuilder.add(ctPropBuilder);
EdmComplexType.Builder ctBuilder = new EdmComplexType.Builder().addProperties(complexTypeBuilder).setName("urlLinks");
EdmComplexType uriCtType = ctBuilder.build();
Settings s = new Settings(ODataVersion.V3, null, null, null, null, true, new EdmCollectionType(CollectionKind.Collection, uriCtType));
JsonLiteCollectionFormatParser jsonLiteCollectionFormatParser = new JsonLiteCollectionFormatParser(s);
OCollection<OComplexObject> linkCollection = (OCollection<OComplexObject>)jsonLiteCollectionFormatParser.parse(reader);
List<SingleLink> rt = new ArrayList<SingleLink>();
for (OComplexObject obj : linkCollection) {
rt.add(SingleLinks.create(obj.getProperty("url", String.class).getValue()));
}
return rt;
}
示例4: parseLinks
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
public static Iterable<SingleLink> parseLinks(Reader reader) {
EdmProperty.Builder ctPropBuilder = EdmProperty.newBuilder("uri").setType(EdmSimpleType.STRING);
List<EdmProperty.Builder> complexTypeBuilder = new ArrayList<EdmProperty.Builder>();
complexTypeBuilder.add(ctPropBuilder);
EdmComplexType.Builder ctBuilder = new EdmComplexType.Builder().addProperties(complexTypeBuilder).setName("uriLinks");
EdmComplexType uriCtType = ctBuilder.build();
Settings s = new Settings(ODataVersion.V2, null, null, null, null, true, new EdmCollectionType(CollectionKind.Collection, uriCtType));
OCollection<OComplexObject> linkCollection = (OCollection<OComplexObject>) new JsonCollectionFormatParser(s).parse(reader);
List<SingleLink> rt = new ArrayList<SingleLink>();
for (OComplexObject obj : linkCollection) {
rt.add(SingleLinks.create(obj.getProperty("uri", String.class).getValue()));
}
return rt;
}
示例5: createComplexTypes
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private void createComplexTypes(EdmDecorator decorator, List<EdmComplexType.Builder> complexTypes) {
for (String complexTypeName : complexTypeInfo.keySet()) {
dump("edm complexType: " + complexTypeName);
InMemoryComplexTypeInfo<?> typeInfo = complexTypeInfo.get(complexTypeName);
List<EdmProperty.Builder> properties = new ArrayList<EdmProperty.Builder>();
// no keys
properties.addAll(toEdmProperties(decorator, typeInfo.propertyModel, new String[] {}, complexTypeName));
EdmComplexType.Builder typeBuilder = EdmComplexType.newBuilder()
.setNamespace(namespace)
.setName(typeInfo.typeName)
.addProperties(properties);
if (decorator != null) {
typeBuilder.setDocumentation(decorator.getDocumentationForEntityType(namespace, complexTypeName));
typeBuilder.setAnnotations(decorator.getAnnotationsForEntityType(namespace, complexTypeName));
}
complexTypes.add(typeBuilder);
}
}
示例6: getMetadata
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private static EdmDataServices getMetadata() {
EdmProperty.Builder dateTimeProperty = EdmProperty.newBuilder(DATETIME_NAME).setType(EdmSimpleType.DATETIME);
EdmProperty.Builder dateTimeOffsetProperty = EdmProperty.newBuilder(DATETIMEOFFSET_NAME).setType(EdmSimpleType.DATETIMEOFFSET);
EdmProperty.Builder timeProperty = EdmProperty.newBuilder(TIME_NAME).setType(EdmSimpleType.TIME);
EdmProperty.Builder booleanProperty = EdmProperty.newBuilder(BOOLEAN_NAME).setType(EdmSimpleType.BOOLEAN);
EdmProperty.Builder stringProperty = EdmProperty.newBuilder(STRING_NAME).setType(EdmSimpleType.STRING);
EdmProperty.Builder guidProperty = EdmProperty.newBuilder(GUID_NAME).setType(EdmSimpleType.GUID);
EdmProperty.Builder decimalProperty = EdmProperty.newBuilder(DECIMAL_NAME).setType(EdmSimpleType.DECIMAL);
EdmProperty.Builder doubleProperty = EdmProperty.newBuilder(DOUBLE_NAME).setType(EdmSimpleType.DOUBLE);
EdmProperty.Builder int16Property = EdmProperty.newBuilder(INT16_NAME).setType(EdmSimpleType.INT16);
EdmEntityType.Builder entityType = new EdmEntityType.Builder().setName("EntityType").addKeys("EntityKey")
.addProperties(dateTimeProperty, dateTimeOffsetProperty, timeProperty, booleanProperty, stringProperty, guidProperty, decimalProperty, doubleProperty, int16Property);
EdmEntitySet.Builder entitySet = new EdmEntitySet.Builder().setName(ENTITYSET_NAME).setEntityType(entityType);
EdmEntityContainer.Builder container = new EdmEntityContainer.Builder().addEntitySets(entitySet);
EdmSchema.Builder schema = new EdmSchema.Builder().addEntityContainers(container).addEntityTypes(entityType);
return new EdmDataServices.Builder().addSchemas(schema).build();
}
示例7: getComplexTypeProperties
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private static List<EdmProperty.Builder> getComplexTypeProperties(
String nodeId,
String name,
List<OEntity> complexPropEntities,
List<OEntity> complexEntities) {
List<EdmProperty.Builder> list = new ArrayList<EdmProperty.Builder>();
for (OEntity oe : complexPropEntities) {
if (!name.equals(
oe.getProperty(ComplexTypeProperty.P_COMPLEXTYPE_NAME.getName()).getValue().toString())) {
continue;
}
Object propValue = oe.getProperty(ComplexTypeProperty.P_NAME.getName().toString()).getValue();
EdmProperty.Builder property = EdmProperty.newBuilder((String) propValue);
setTypeProperty(nodeId, ComplexTypeProperty.P_TYPE.getName().toString(), oe, complexEntities, property);
propValue = oe.getProperty(ComplexTypeProperty.P_NULLABLE.getName().toString());
if (propValue != null) {
propValue = ((OProperty<?>) propValue).getValue();
property.setNullable((Boolean) propValue);
}
propValue = oe.getProperty(ComplexTypeProperty.P_DEFAULT_VALUE.getName().toString()).getValue();
property.setDefaultValue((String) propValue);
propValue = oe.getProperty(ComplexTypeProperty.P_COLLECTION_KIND.getName().toString()).getValue();
if (propValue == null || "None".equals(propValue)) {
property.setCollectionKind(CollectionKind.NONE);
} else {
property.setCollectionKind(CollectionKind.valueOf((String) propValue));
}
list.add(property);
}
return list;
}
示例8: setTypeProperty
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private static void setTypeProperty(String nodeId, String typeName, OEntity oe,
List<OEntity> complexEntities,
EdmProperty.Builder property) {
String complexTypeName = (String) ((OProperty<?>) oe.getProperty(typeName)).getValue();
EdmType type = EdmSimpleType.getSimple(complexTypeName);
if (type == null) {
if (isExistComplexTypeEntity(complexTypeName, complexEntities)) {
property.setType(EdmComplexType.newBuilder().setNamespace(nodeId).setName(complexTypeName));
}
} else {
property.setType(type);
}
}
示例9: parseEdmComplexType
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* parseEdmComplexType.
* @param reader reader
* @param schemaNamespace schemaNamespace
* @param complexTypeElement complexTypeElement
* @return EdmComplexType.Builder
*/
private EdmComplexType.Builder parseEdmComplexType(
XMLEventReader2 reader, String schemaNamespace, StartElement2 complexTypeElement) {
String name = complexTypeElement.getAttributeByName("Name").getValue();
String isAbstractS = getAttributeValueIfExists(complexTypeElement, "Abstract");
List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_PROPERTY, EDM2009_PROPERTY)) {
edmProperties.add(parseEdmProperty(event));
}
if (isEndElement(event, complexTypeElement.getName())) {
EdmComplexType.Builder complexType = EdmComplexType.newBuilder()
.setNamespace(schemaNamespace).setName(name).addProperties(edmProperties);
if (isAbstractS != null) {
complexType.setIsAbstract("true".equals(isAbstractS));
}
return complexType;
}
}
throw new UnsupportedOperationException();
}
示例10:
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private EdmComplexType.Builder EntityTypeにcomplex型Propertyを1つ作成(String complexTypeName,
EdmEntityType.Builder builder) {
EdmComplexType.Builder ctBuilder = EdmComplexType.newBuilder();
ctBuilder.setName(complexTypeName).setNamespace(NS);
EdmProperty.Builder pBuilder = EdmProperty.newBuilder(complexTypeName + "_prop")
.setType(ctBuilder);
builder.addProperties(pBuilder);
return ctBuilder;
}
示例11: parseEdmComplexType
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private EdmComplexType.Builder parseEdmComplexType(XMLEventReader2 reader, String schemaNamespace, StartElement2 complexTypeElement) {
String name = complexTypeElement.getAttributeByName("Name").getValue();
String isAbstractS = getAttributeValueIfExists(complexTypeElement, "Abstract");
String baseType = getAttributeValueIfExists(complexTypeElement, "BaseType");
List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isStartElement()) {
if (isElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_1_PROPERTY, EDM2008_9_PROPERTY, EDM2009_8_PROPERTY, EDM2009_11_PROPERTY)) {
edmProperties.add(parseEdmProperty(reader, event));
} else {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
}
if (isEndElement(event, complexTypeElement.getName())) {
EdmComplexType.Builder complexType = EdmComplexType.newBuilder()
.setNamespace(schemaNamespace)
.setName(name)
.setBaseType(baseType)
.addProperties(edmProperties)
.setAnnotations(getAnnotations(complexTypeElement))
.setAnnotationElements(annotElements);
if (isAbstractS != null)
complexType.setIsAbstract("true".equals(isAbstractS));
return complexType;
}
}
throw new UnsupportedOperationException();
}
示例12: edmPropertyMimeType
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
@Test
public void edmPropertyMimeType() {
EdmProperty.Builder builder = EdmProperty.newBuilder("Name");
EdmProperty property = builder.setMimeType(MIMETYPE).setType(EdmSimpleType.STRING).build();
assertEquals(MIMETYPE, property.getMimeType());
}
示例13: testPrecisionAndScale
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
@Test
public void testPrecisionAndScale() {
// build simplest edm containing one decimal property
EdmProperty.Builder edmPropertyBuilder = EdmProperty.newBuilder("DecimalProperty").setType(EdmSimpleType.DECIMAL).setPrecision(2).setScale(10);
List<EdmProperty.Builder> builderProperties = new ArrayList<EdmProperty.Builder>();
builderProperties.add(edmPropertyBuilder);
List<String> keys = new ArrayList<String>();
keys.add("DecimalProperty");
EdmEntityType.Builder entityTypeBuilder = EdmEntityType.newBuilder().setName("TypeName");
entityTypeBuilder.addProperties(builderProperties);
entityTypeBuilder.addKeys(keys);
ArrayList<EdmEntityType.Builder> builderEntityTypes = new ArrayList<EdmEntityType.Builder>();
builderEntityTypes.add(entityTypeBuilder);
EdmSchema.Builder edmSchemaBuilder = EdmSchema.newBuilder().setNamespace("Namespace");
edmSchemaBuilder.addEntityTypes(builderEntityTypes);
EdmDataServices.Builder edmDataServiceBuilder = EdmDataServices.newBuilder();
edmDataServiceBuilder.addSchemas(edmSchemaBuilder);
// print xml
StringWriter sw = new StringWriter();
EdmxFormatWriter.write(edmDataServiceBuilder.build(), sw);
String edmAsString = sw.toString();
// check it
assertTrue(edmAsString.contains("<Property Name=\"DecimalProperty\" Type=\"Edm.Decimal\" Nullable=\"false\" Precision=\"2\" Scale=\"10\"></Property>"));
}
示例14: ensureMetadataWithArrayOrObjectCanBeParsed
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
@Test
public void ensureMetadataWithArrayOrObjectCanBeParsed() throws Exception {
StringReader json = new StringReader("" +
"{ \"d\": {" +
"\"__metadata\": {" +
"\"uri\": \"http://localhost:8180/databinding/odata.svc/Products(2)\"," +
"\"uri_extensions\": []," + // (empty) array
"\"edit\": \"http://localhost:8180/databinding/odata.svc/Products(2)\"," +
"\"edit_link_extensions\": [ { \"name\": \"title\", \"namespaceURI\": null, \"value\": \"Products\" } ]," + // array
"\"properties\": { \"id\": { \"type\": \"Edm.Int32\", \"extensions\": [] }, \"price\": { \"type\": \"Edm.Double\", \"extensions\": [] }, \"name\": { \"type\": \"Edm.String\", \"extensions\": [] }, }," + // object
"\"type\": \"SampleAppModel.Products\"," +
"\"type_extensions\": []" + // (empty) array
"}," +
"\"id\": 2, \"price\": \"235\", \"name\": \"Product ABC\" } }");
// build metadata
EdmProperty.Builder productIdProperty = EdmProperty.newBuilder("id").setType(EdmSimpleType.INT32);
EdmProperty.Builder priceProperty = EdmProperty.newBuilder("price").setType(EdmSimpleType.DOUBLE);
EdmProperty.Builder productNameProperty = EdmProperty.newBuilder("name").setType(EdmSimpleType.STRING);
EdmEntityType.Builder productsEntityType = new EdmEntityType.Builder().setNamespace("SampleAppModel").setName("Products").addKeys("id").addProperties(productIdProperty, priceProperty, productNameProperty);
EdmEntitySet.Builder productsEntitySet = new EdmEntitySet.Builder().setName("Products").setEntityType(productsEntityType);
EdmEntityContainer.Builder container = new EdmEntityContainer.Builder().addEntitySets(productsEntitySet);
EdmSchema.Builder schema = new EdmSchema.Builder().addEntityContainers(container).addEntityTypes(productsEntityType);
EdmDataServices metadata = new EdmDataServices.Builder().addSchemas(schema).build();
FormatParser<Feed> formatParser = FormatParserFactory.getParser(Feed.class, FormatType.JSONVERBOSE, new Settings(ODataVersion.V1, metadata, "Products", null, null));
assertThat(formatParser.parse(json), notNullValue());
}
示例15: createComplexTypes
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private void createComplexTypes() {
// ----------------------------- ComplexType1 --------------------------
List<EdmProperty.Builder> props = new ArrayList<EdmProperty.Builder>();
EdmProperty.Builder ep = EdmProperty.newBuilder("Prop1").setType(EdmSimpleType.STRING);
props.add(ep);
ep = EdmProperty.newBuilder("Prop2").setType(EdmSimpleType.STRING);
props.add(ep);
complexType = EdmComplexType.newBuilder().setNamespace(namespace).setName("ComplexType1").addProperties(props);
complexTypes.add(complexType);
}