本文整理汇总了Java中org.odata4j.edm.EdmProperty.getCollectionKind方法的典型用法代码示例。如果您正苦于以下问题:Java EdmProperty.getCollectionKind方法的具体用法?Java EdmProperty.getCollectionKind怎么用?Java EdmProperty.getCollectionKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.odata4j.edm.EdmProperty
的用法示例。
在下文中一共展示了EdmProperty.getCollectionKind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSimpleListProperty
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* シンプルタイプの配列要素をプロパティに追加する.
* @param properties プロパティ一覧
* @param edmProp 追加プロパティのスキーマ
* @param propValue 追加プロカティの値
* @param edmType タイプの型情報
*/
@SuppressWarnings("unchecked")
protected void addSimpleListProperty(List<OProperty<?>> properties,
EdmProperty edmProp,
Object propValue,
EdmType edmType) {
EdmCollectionType collectionType = new EdmCollectionType(edmProp.getCollectionKind(), edmType);
OCollection.Builder<OObject> builder = OCollections.<OObject>newBuilder(collectionType.getItemType());
if (propValue == null) {
properties.add(OProperties.collection(edmProp.getName(), collectionType, null));
} else {
for (Object val : (ArrayList<Object>) propValue) {
if (null == val) {
builder.add(OSimpleObjects.parse((EdmSimpleType<?>) collectionType.getItemType(), null));
} else {
builder.add(OSimpleObjects.parse((EdmSimpleType<?>) collectionType.getItemType(), val.toString()));
}
}
properties.add(OProperties.collection(edmProp.getName(), collectionType, builder.build()));
}
}
示例2: addComplexListProperty
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* Complexタイプの配列要素をプロパティに追加する.
* @param metadata スキーマ情報
* @param properties プロパティ一覧
* @param edmProp 追加プロパティのスキーマ
* @param propValue 追加プロカティの値
* @param edmType タイプの型情報
*/
@SuppressWarnings("unchecked")
protected void addComplexListProperty(EdmDataServices metadata,
List<OProperty<?>> properties,
EdmProperty edmProp,
Object propValue,
EdmType edmType) {
EdmCollectionType collectionType = new EdmCollectionType(edmProp.getCollectionKind(), edmType);
OCollection.Builder<OObject> builder = OCollections.<OObject>newBuilder(collectionType.getItemType());
// ComplexTypeの型情報を取得する
EdmComplexType ct = metadata.findEdmComplexType(
collectionType.getItemType().getFullyQualifiedTypeName());
if (propValue == null) {
properties.add(OProperties.collection(edmProp.getName(), collectionType, null));
} else {
// ComplexTypeプロパティを配列に追加する
for (Object val : (ArrayList<Object>) propValue) {
builder.add(OComplexObjects.create(ct, getComplexTypePropList(metadata, edmProp, val)));
}
// ComplexTypeの配列要素をプロパティに追加する
properties.add(OProperties.collection(edmProp.getName(), collectionType, builder.build()));
}
}
示例3: getComplexTypePropList
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* ComplexType型のプロパティをOPropertyの配列に変換する.
* @param metadata スキーマ定義
* @param prop ComplexType型のプロパティ
* @param value ComplexType型の値
* @return OPropertyの配列
*/
@SuppressWarnings("unchecked")
protected List<OProperty<?>> getComplexTypePropList(EdmDataServices metadata,
EdmProperty prop,
Object value) {
if (value == null) {
return null;
}
List<OProperty<?>> props = new ArrayList<OProperty<?>>();
// スキーマ定義からComplexType定義を取得する
EdmComplexType edmComplexType = metadata.findEdmComplexType(prop.getType().getFullyQualifiedTypeName());
HashMap<String, Object> valMap = (HashMap<String, Object>) value;
for (EdmProperty propChild : edmComplexType.getDeclaredProperties()) {
String typeName = propChild.getDeclaringType().getName();
Object valChild = valMap.get(resolveComplexTypeAlias(propChild.getName(), typeName));
EdmType edmType = propChild.getType();
CollectionKind ck = propChild.getCollectionKind();
if (edmType.isSimple()) {
// 非予約項目の処理
if (ck.equals(CollectionKind.List)) {
// 配列要素の場合
addSimpleListProperty(props, propChild, valChild, edmType);
} else {
// シンプル要素の場合
addSimpleTypeProperty(props, propChild, valChild, edmType);
}
} else {
if (ck.equals(CollectionKind.List)) {
// 配列要素の場合
addComplexListProperty(metadata, props, propChild, valChild, edmType);
} else {
props.add(createComplexTypeProperty(metadata, propChild, valChild));
}
}
}
return props;
}
示例4: getComplexType
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* ComplexTypeのプロパティを読み込み取得する.
* @param property プロパティList
* @return
*/
@SuppressWarnings("unchecked")
private Object getComplexType(List<OProperty<?>> props, EdmDataServices metadata, String complexTypeName) {
// 指定されたPropertyの値を取得する
Map<String, Object> complex = new HashMap<String, Object>();
if (props == null) {
return null;
}
// ComplexTypeのPropertyをHashに追加する
for (OProperty<?> prop : props) {
EdmProperty edmProp = metadata.findEdmComplexType(complexTypeName).findProperty(prop.getName());
CollectionKind ck = edmProp.getCollectionKind();
if (edmProp.getType().isSimple()) {
if (ck.equals(CollectionKind.List)) {
// 不正な型の場合はエラー
if (prop.getValue() == null || prop.getValue() instanceof OCollection<?>) {
complex.put(prop.getName(),
getSimpleList(edmProp.getType(), (OCollection<OObject>) prop.getValue()));
} else {
throw PersoniumCoreException.OData.REQUEST_FIELD_FORMAT_ERROR.params(prop.getName());
}
} else {
Object value = getSimpleValue(prop, edmProp.getType());
// PropertyがSimple型の場合はそのまま定義済み項目として追加する
complex.put(prop.getName(), value);
}
} else {
// PropertyがComplex型の場合は再帰的にComplexTypeのプロパティを読み込み追加する
String propComplexTypeName = edmProp.getType().getFullyQualifiedTypeName();
if (ck.equals(CollectionKind.List)) {
// CollectionKindがListの場合は、配列で追加する
complex.put(
prop.getName(),
getComplexList((OCollection<OComplexObject>) prop.getValue(),
metadata, propComplexTypeName));
} else {
// PropertyがComplex型の場合は再帰的にComplexTypeのプロパティを読み込み追加する
complex.put(prop.getName(),
getComplexType(prop, metadata, propComplexTypeName));
}
}
}
return complex;
}
示例5: createProperties
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* Edmxに定義されているProperty/ComplexTypePropertyを登録する.
* @param entity 登録対象のPropertyが定義されているEntityType/ComplexTypeオブジェクト
* @param davCmp Collection操作用オブジェクト
* @param producer ODataプロデューサー
*/
@SuppressWarnings("unchecked")
protected void createProperties(EdmStructuralType entity, DavCmp davCmp, PersoniumODataProducer producer) {
Iterable<EdmProperty> properties = entity.getDeclaredProperties();
EdmDataServices userMetadata = null;
String edmTypeName = Property.EDM_TYPE_NAME;
if (entity instanceof EdmComplexType) {
edmTypeName = ComplexTypeProperty.EDM_TYPE_NAME;
}
for (EdmProperty property : properties) {
String name = property.getName();
log.debug(edmTypeName + ": " + name);
if (name.startsWith("_")) {
continue;
}
if (userMetadata == null) {
userMetadata = CtlSchema.getEdmDataServicesForODataSvcSchema().build();
odataEntityResource.setEntitySetName(edmTypeName);
}
CollectionKind kind = property.getCollectionKind();
if (kind != null && !kind.equals(CollectionKind.NONE) && !kind.equals(CollectionKind.List)) {
throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(METADATA_XML);
}
JSONObject json = new JSONObject();
json.put("Name", property.getName());
if (entity instanceof EdmComplexType) {
json.put("_ComplexType.Name", entity.getName());
} else {
json.put("_EntityType.Name", entity.getName());
json.put("IsKey", false); // Iskey対応時に設定する必要あり
json.put("UniqueKey", null); // UniqueKey対応時に設定する必要あり
}
String typeName = property.getType().getFullyQualifiedTypeName();
if (!property.getType().isSimple() && typeName.startsWith("UserData.")) {
typeName = typeName.replace("UserData.", "");
}
json.put("Type", typeName);
json.put("Nullable", property.isNullable());
json.put("DefaultValue", property.getDefaultValue());
json.put("CollectionKind", property.getCollectionKind().toString());
StringReader stringReader = new StringReader(json.toJSONString());
OEntityWrapper oew = odataEntityResource.getOEntityWrapper(stringReader,
odataEntityResource.getOdataResource(), userMetadata);
// ComplexTypePropertyの登録
producer.createEntity(edmTypeName, oew);
}
}
示例6: getProperty
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
private OEntity getProperty(EdmStructuralType queryType, EdmStructuralType et, EdmProperty p, Context c) {
List<OProperty<?>> props = new ArrayList<OProperty<?>>();
if (c.pathHelper.isSelected(Edm.Property.Namespace)) {
props.add(OProperties.string(Edm.Property.Namespace, et.getNamespace()));
}
if (c.pathHelper.isSelected(Edm.Property.EntityTypeName)) {
props.add(OProperties.string(Edm.Property.EntityTypeName, et.getName()));
}
if (c.pathHelper.isSelected(Edm.Property.Name)) {
props.add(OProperties.string(Edm.Property.Name, p.getName()));
}
if (c.pathHelper.isSelected(Edm.Property.Type)) {
props.add(OProperties.string(Edm.Property.Type, p.getType().getFullyQualifiedTypeName()));
}
if (c.pathHelper.isSelected(Edm.Property.Nullable)) {
props.add(OProperties.boolean_(Edm.Property.Nullable, p.isNullable()));
}
if (p.getDefaultValue() != null && c.pathHelper.isSelected(Edm.Property.DefaultValue)) {
props.add(OProperties.string(Edm.Property.DefaultValue, p.getDefaultValue()));
}
if (p.getMaxLength() != null && c.pathHelper.isSelected(Edm.Property.MaxLength)) {
props.add(OProperties.int32(Edm.Property.MaxLength, p.getMaxLength()));
}
if (p.getFixedLength() != null && c.pathHelper.isSelected(Edm.Property.FixedLength)) {
props.add(OProperties.boolean_(Edm.Property.FixedLength, p.getFixedLength()));
}
if (p.getPrecision() != null && c.pathHelper.isSelected(Edm.Property.Precision)) {
props.add(OProperties.int32(Edm.Property.Precision, p.getPrecision()));
}
if (p.getScale() != null && c.pathHelper.isSelected(Edm.Property.Scale)) {
props.add(OProperties.int32(Edm.Property.Scale, p.getScale()));
}
if (p.getUnicode() != null && c.pathHelper.isSelected(Edm.Property.Unicode)) {
props.add(OProperties.boolean_(Edm.Property.Unicode, p.getUnicode()));
}
// TODO: collation
// TODO: ConcurrencyMode
if (p.getCollectionKind() != CollectionKind.NONE) {
props.add(OProperties.string(Edm.Property.CollectionKind, p.getCollectionKind().toString()));
}
this.addDocumenation(c, p, props);
addAnnotationProperties(c, p, props);
EdmEntitySet entitySet = edm.findEdmEntitySet(Edm.EntitySets.Properties);
if (this.decorator != null) {
this.decorator.decorateEntity(entitySet, p, queryType, props, c.flatten, c.locale, c.queryInfo != null ? c.queryInfo.customOptions : null);
}
return OEntities.create(entitySet,
OEntityKey.create(Edm.Property.Namespace, et.getNamespace(), Edm.Property.EntityTypeName, et.getName(), Edm.Property.Name, p.getName()),
props,
Collections.<OLink> emptyList());
}
示例7: fillInPojo
import org.odata4j.edm.EdmProperty; //导入方法依赖的package包/类
/**
* Populates a new POJO instance of type pojoClass using data from the given structural object.
*/
protected <T> T fillInPojo(OStructuralObject sobj, EdmStructuralType stype, PropertyModel propertyModel,
Class<T> pojoClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
T pojo = pojoClass.newInstance();
fireUnmarshalEvent(pojo, sobj, TriggerType.Before);
for (Iterator<EdmProperty> it = stype.getProperties().iterator(); it.hasNext();) {
EdmProperty property = it.next();
Object value = null;
try {
value = sobj.getProperty(property.getName()).getValue();
} catch (Exception ex) {
// property not define on object
if (property.isNullable()) {
continue;
} else {
throw new RuntimeException("missing required property " + property.getName());
}
}
if (property.getCollectionKind() == EdmProperty.CollectionKind.NONE) {
if (property.getType().isSimple()) {
// call the setter.
propertyModel.setPropertyValue(pojo, property.getName(), value);
} else {
// complex.
// hmmh, value is a Collection<OProperty<?>>...why is it not an OComplexObject.
propertyModel.setPropertyValue(
pojo,
property.getName(),
value == null
? null
: toPojo(
OComplexObjects.create((EdmComplexType) property.getType(), (List<OProperty<?>>) value),
propertyModel.getPropertyType(property.getName())));
}
} else {
// collection.
OCollection<? extends OObject> collection = (OCollection<? extends OObject>) value;
List<Object> pojos = new ArrayList<Object>();
for (OObject item : collection) {
if (collection.getType().isSimple()) {
pojos.add(((OSimpleObject<?>) item).getValue());
} else {
// turn OComplexObject into a pojo
pojos.add(toPojo((OComplexObject) item, propertyModel.getCollectionElementType(property.getName())));
}
}
propertyModel.setCollectionValue(pojo, property.getName(), pojos);
}
}
return pojo;
}