本文整理汇总了Java中org.ofbiz.entity.model.ModelKeyMap类的典型用法代码示例。如果您正苦于以下问题:Java ModelKeyMap类的具体用法?Java ModelKeyMap怎么用?Java ModelKeyMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelKeyMap类属于org.ofbiz.entity.model包,在下文中一共展示了ModelKeyMap类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addConstraint
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public void addConstraint(ProductSearchContext productSearchContext) {
List<String> productCategoryIds = FastList.newInstance();
for (GenericValue category: productCategories) {
productCategoryIds.add(category.getString("productCategoryId"));
}
// make index based values and increment
String entityAlias = "PCM" + productSearchContext.index;
String prefix = "pcm" + productSearchContext.index;
productSearchContext.index++;
productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "ProductCategoryMember");
productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductCategoryId", "productCategoryId", null, null, null, null);
productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null);
productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductCategoryId", EntityOperator.IN, productCategoryIds));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp)));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, productSearchContext.nowTimestamp));
// add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later
productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.prodCatalogId)));
}
示例2: setSortOrder
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public void setSortOrder(ProductSearchContext productSearchContext) {
productSearchContext.dynamicViewEntity.addMemberEntity("PFAPPL", "ProductFeatureAndAppl");
productSearchContext.dynamicViewEntity.addAlias("PFAPPL", "sortProductFeatureTypeId", "productFeatureTypeId", null, null, null, null);
productSearchContext.dynamicViewEntity.addAlias("PFAPPL", "sortProductFeatureId", "productFeatureId", null, null, null, null);
productSearchContext.dynamicViewEntity.addAlias("PFAPPL", "sortFromDate", "fromDate", null, null, null, null);
productSearchContext.dynamicViewEntity.addAlias("PFAPPL", "sortThruDate", "thruDate", null, null, null, null);
productSearchContext.dynamicViewEntity.addViewLink("PROD", "PFAPPL", Boolean.TRUE, UtilMisc.toList(new ModelKeyMap("productId", "productId")));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition("sortProductFeatureTypeId", EntityOperator.EQUALS, this.productFeatureTypeId));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition("sortFromDate", EntityOperator.LESS_THAN_EQUAL_TO, productSearchContext.nowTimestamp));
productSearchContext.entityConditionList.add(EntityCondition.makeCondition(
EntityCondition.makeCondition("sortThruDate", EntityOperator.EQUALS, null), EntityOperator.OR,
EntityCondition.makeCondition("sortThruDate", EntityOperator.GREATER_THAN_EQUAL_TO, productSearchContext.nowTimestamp)));
if (ascending) {
productSearchContext.orderByList.add("+sortProductFeatureId");
} else {
productSearchContext.orderByList.add("-sortProductFeatureId");
}
productSearchContext.fieldsToSelect.add("sortProductFeatureId");
}
示例3: addConstraint
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public void addConstraint(WorkEffortSearchContext workEffortSearchContext) {
// make index based values and increment
String entityAlias = "WEPA" + workEffortSearchContext.index;
String prefix = "wepa" + workEffortSearchContext.index;
workEffortSearchContext.index++;
workEffortSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortPartyAssignment");
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "PartyId", "partyId", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "RoleTypeId", "roleTypeId", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "PartyId", EntityOperator.EQUALS, partyId));
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, workEffortSearchContext.nowTimestamp)));
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, workEffortSearchContext.nowTimestamp));
if (UtilValidate.isNotEmpty(this.roleTypeId)) {
workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "RoleTypeId", EntityOperator.EQUALS, roleTypeId));
}
// add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later
workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.partyId + "," + this.roleTypeId)));
}
示例4: removeRelated
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
@Deprecated
public int removeRelated(String relationName, GenericValue value, boolean doCacheClear) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
Map<String, Object> fields = new HashMap<String, Object>();
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.removeByAnd(relation.getRelEntityName(), fields, doCacheClear);
}
示例5: getRelated
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public List<GenericValue> getRelated(String relationName, Map<String, ? extends Object> byAndFields, List<String> orderBy, GenericValue value, boolean useCache) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
// put the byAndFields (if not null) into the hash map first,
// they will be overridden by value's fields if over-specified this is important for security and cleanliness
Map<String, Object> fields = new HashMap<String, Object>();
if (byAndFields != null) {
fields.putAll(byAndFields);
}
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.findByAnd(relation.getRelEntityName(), fields, orderBy, useCache);
}
示例6: getRelatedDummyPK
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public GenericPK getRelatedDummyPK(String relationName, Map<String, ? extends Object> byAndFields, GenericValue value) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
ModelEntity relatedEntity = getModelReader().getModelEntity(relation.getRelEntityName());
// put the byAndFields (if not null) into the hash map first,
// they will be overridden by value's fields if over-specified this is important for security and cleanliness
Map<String, Object> fields = new HashMap<String, Object>();
if (byAndFields != null) {
fields.putAll(byAndFields);
}
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return GenericPK.create(this, relatedEntity, fields);
}
示例7: getRelatedOne
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Override
public GenericValue getRelatedOne(String relationName, GenericValue value, boolean useCache) throws GenericEntityException {
ModelRelation relation = value.getModelEntity().getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
if (!"one".equals(relation.getType()) && !"one-nofk".equals(relation.getType())) {
throw new GenericModelException("Relation is not a 'one' or a 'one-nofk' relation: " + relationName + " of entity " + value.getEntityName());
}
Map<String, Object> fields = new HashMap<String, Object>();
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.findOne(relation.getRelEntityName(), fields, useCache);
}
示例8: removeRelated
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
@Deprecated
public int removeRelated(String relationName, GenericValue value, boolean doCacheClear) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
Map<String, Object> fields = new HashMap<String, Object>();
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.removeByAnd(relation.getRelEntityName(), fields, doCacheClear);
}
示例9: getRelated
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
public List<GenericValue> getRelated(String relationName, Map<String, ? extends Object> byAndFields, List<String> orderBy, GenericValue value, boolean useCache) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
// put the byAndFields (if not null) into the hash map first,
// they will be overridden by value's fields if over-specified this is important for security and cleanliness
Map<String, Object> fields = new HashMap<String, Object>();
if (byAndFields != null) {
fields.putAll(byAndFields);
}
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.findByAnd(relation.getRelEntityName(), fields, orderBy, useCache);
}
示例10: getRelatedDummyPK
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
public GenericPK getRelatedDummyPK(String relationName, Map<String, ? extends Object> byAndFields, GenericValue value) throws GenericEntityException {
ModelEntity modelEntity = value.getModelEntity();
ModelRelation relation = modelEntity.getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
ModelEntity relatedEntity = getModelReader().getModelEntity(relation.getRelEntityName());
// put the byAndFields (if not null) into the hash map first,
// they will be overridden by value's fields if over-specified this is important for security and cleanliness
Map<String, Object> fields = new HashMap<String, Object>();
if (byAndFields != null) {
fields.putAll(byAndFields);
}
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return GenericPK.create(this, relatedEntity, fields);
}
示例11: getRelatedOne
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
public GenericValue getRelatedOne(String relationName, GenericValue value, boolean useCache) throws GenericEntityException {
ModelRelation relation = value.getModelEntity().getRelation(relationName);
if (relation == null) {
throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value);
}
if (!"one".equals(relation.getType()) && !"one-nofk".equals(relation.getType())) {
throw new GenericModelException("Relation is not a 'one' or a 'one-nofk' relation: " + relationName + " of entity " + value.getEntityName());
}
Map<String, Object> fields = new HashMap<String, Object>();
for (ModelKeyMap keyMap : relation.getKeyMaps()) {
fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName()));
}
return this.findOne(relation.getRelEntityName(), fields, useCache);
}
示例12: ProductSearchContext
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
public ProductSearchContext(Delegator delegator, String visitId) {
this.delegator = delegator;
this.visitId = visitId;
dynamicViewEntity.addMemberEntity("PROD", "Product");
dynamicViewEntity.addMemberEntity("PRODCI", "ProductCalculatedInfo");
dynamicViewEntity.addViewLink("PROD", "PRODCI", Boolean.TRUE, ModelKeyMap.makeKeyMapList("productId"));
}
示例13: getRelationFieldNames
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
/**
* Returns the field names of the entity that are foreign keys to the specified relEntityName.
* Only useful if relEntityName is entity with single-field PK.
*/
public static Set<String> getRelationFieldNames(ModelEntity modelEntity, String relEntityName,
boolean includeOne, boolean includeOneNoFk, boolean includeMany) {
if (modelEntity == null) return null;
Set<String> fieldNames = new LinkedHashSet<>(); // NOTE: using LinkedHashSet so order is more predictable...
for(ModelRelation relation : modelEntity.getRelationsList(includeOne, includeOneNoFk, includeMany)) {
if (relEntityName.equals(relation.getRelEntityName())) {
for(ModelKeyMap keyMap : relation.getKeyMaps()) {
fieldNames.add(keyMap.getFieldName());
}
}
}
return fieldNames;
}
示例14: makeFkIndexClause
import org.ofbiz.entity.model.ModelKeyMap; //导入依赖的package包/类
public String makeFkIndexClause(ModelEntity entity, ModelRelation modelRelation, int constraintNameClipLength) {
StringBuilder mainCols = new StringBuilder();
for (ModelKeyMap keyMap : modelRelation.getKeyMaps()) {
ModelField mainField = entity.getField(keyMap.getFieldName());
if (mainField == null) {
Debug.logError("Bad key-map in entity [" + entity.getEntityName() + "] relation to [" + modelRelation.getTitle() + modelRelation.getRelEntityName() + "] for field [" + keyMap.getFieldName() + "]", module);
return null;
}
if (mainCols.length() > 0) {
mainCols.append(", ");
}
mainCols.append(mainField.getColName());
}
StringBuilder indexSqlBuf = new StringBuilder("CREATE INDEX ");
String relConstraintName = makeFkConstraintName(modelRelation, constraintNameClipLength);
indexSqlBuf.append(relConstraintName);
indexSqlBuf.append(" ON ");
indexSqlBuf.append(entity.getTableName(datasourceInfo));
indexSqlBuf.append(" (");
indexSqlBuf.append(mainCols.toString());
indexSqlBuf.append(")");
return indexSqlBuf.toString();
}