package com.persagy.proxy.adm.strategy; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; import com.persagy.dmp.basic.dto.RequestData; import com.persagy.dmp.digital.entity.ObjectDigital; import com.persagy.proxy.adm.model.AdmRelationObject; import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy; /** * 获取关系对象的上下文类 * * @version 1.0.0 * @company persagy * @author zhangqiankun * @date 2021年9月2日 下午10:44:32 */ @Component public class RelationObjectContext { /** * 策略执行类 */ private Map relationObjectStrategyMap; /** * @param relationObjectStrategyMap */ @Resource public void relationObjectStrategyMap(Map relationObjectStrategyMap) { this.relationObjectStrategyMap = relationObjectStrategyMap; } /** * 获取关系对象数据 * * @param groupCode * @param projectId * @param relType graphCode_relCode * @return */ public List exportRelationObject(String groupCode, String projectId, String relType) { RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); return strategy == null ? Lists.newArrayList() : strategy.exportRelationObject(groupCode, projectId); } /** * 检查关联对象的合法性 * * @param relationObject 当前需要校验的对象 * @param relType graphCode_relCode * @param code 获取对象的依据 * @return String - 校验失败的原因, ObjectNode -- BDTP接口的参数,不会返回null,请用instanceOf 判断返回值 */ public Object checkRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String relType, String code) { RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); return strategy == null ? "不存在此策略类" : strategy.beforeSaveRelationObject(relationObject, groupCode, projectId, code); } /** * 批量保存对象之间的关系 * * @param admRelationObject * @param groupCode * @param projectId * @param relType graphCode_relCode * @return */ public boolean saveRelationObjects(List relationObjects, String groupCode, String projectId, String relType) { RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); return strategy == null ? false : strategy.saveRelationObjects(relationObjects, groupCode, projectId); } /** * 统计关系总数 * * @param groupCode * @param projectId * @param relType graphCode_relCode * @return */ public long countRelationObjects(String groupCode, String projectId, String relType) { RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); return strategy == null ? 0 : strategy.countRelationObjects(groupCode, projectId); } /** * 查询全部的关系对象数据 * * @param masterObjs 查询的数据集存储地方 * @param requestData 请求参数 * @param groupCode 集团编码 * @param projectId 项目ID * @param relType graphCode_relCode */ public List queryAllRelations(String groupCode, String projectId, String relType) { RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); return strategy == null ? Lists.newArrayList() : strategy.queryAllRelations(groupCode, projectId); } /** * 分页查询关系对象数据 * * @param masterObjs 查询的数据集存储地方 * @param requestData 请求参数 * @param groupCode 集团编码 * @param projectId 项目ID * @param relType graphCode_relCode */ public List queryPageRelations(RequestData requestData, String groupCode, String projectId, String relType) { List masterObjs = new ArrayList(); RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType); if (strategy == null) { return masterObjs; } strategy.queryPageRelations(masterObjs, requestData, groupCode, projectId); return masterObjs; } }