Commit 21fa7752 authored by shyWang's avatar shyWang

PDM前端改造

基线相关接口
parent abb72b07
...@@ -42,6 +42,12 @@ public class SearchOperatorEnumUtil { ...@@ -42,6 +42,12 @@ public class SearchOperatorEnumUtil {
public static final String DX_VIEWID = "dxViewId"; public static final String DX_VIEWID = "dxViewId";
public static final String DX_CONTEXT_NAME = "dxContext-name";
public static final String DX_FOLDER_ID = "folderName";
public static final String DX_SUBTYPE_NAME = "subTypeName";
public static final String DX_ID = "id"; public static final String DX_ID = "id";
public static final String DX_NAME = "name"; public static final String DX_NAME = "name";
......
...@@ -15,6 +15,7 @@ import com.yonde.change.vo.pr.DxProblemReportVo; ...@@ -15,6 +15,7 @@ import com.yonde.change.vo.pr.DxProblemReportVo;
import com.yonde.common.*; import com.yonde.common.*;
import com.yonde.doc.vo.DxDocumentVO; import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO; import com.yonde.part.vo.DxPartVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -102,7 +103,7 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess { ...@@ -102,7 +103,7 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess {
} }
if (wtObjectById instanceof ManagedBaseline) { if (wtObjectById instanceof ManagedBaseline) {
ManagedBaseline baseline = (ManagedBaseline) wtObjectById; ManagedBaseline baseline = (ManagedBaseline) wtObjectById;
idVO = new DxBaselineVO(baseline); idVO = new DxBaselineVO(baseline, false);
return idVO; return idVO;
} }
if (wtObjectById instanceof EPMDocument) { if (wtObjectById instanceof EPMDocument) {
...@@ -136,7 +137,7 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess { ...@@ -136,7 +137,7 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess {
} else { } else {
o = (WTObject) element; o = (WTObject) element;
} }
DxSearchUtil.buildQueryResult(o, partList, indices); DxSearchUtil.buildQueryResult(o, partList, searchQueryCondition);
} }
resultMap.put("totalSize", queryResult.getTotalSize()); resultMap.put("totalSize", queryResult.getTotalSize());
resultMap.put("result", partList); resultMap.put("result", partList);
......
...@@ -7,13 +7,13 @@ import com.yonde.basedata.vo.RevisionControlledVO; ...@@ -7,13 +7,13 @@ import com.yonde.basedata.vo.RevisionControlledVO;
import com.yonde.baseline.service.DxBaselineService; import com.yonde.baseline.service.DxBaselineService;
import com.yonde.baseline.vo.DxBaselineVO; import com.yonde.baseline.vo.DxBaselineVO;
import com.yonde.common.ObjectsUtil; import com.yonde.common.ObjectsUtil;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
@RestController
@RequestMapping({"/DxBaseline"})
public class DxBaselineController extends AbstractBaseController { public class DxBaselineController extends AbstractBaseController {
//@ApiOperation("获取基线成员矩阵") //@ApiOperation("获取基线成员矩阵")
...@@ -32,18 +32,33 @@ public class DxBaselineController extends AbstractBaseController { ...@@ -32,18 +32,33 @@ public class DxBaselineController extends AbstractBaseController {
//@ApiOperation("基线冻结") //@ApiOperation("基线冻结")
@PostMapping({"/frozen/{id}"}) @PostMapping({"/frozen/{id}"})
public ApiResult frozen(@PathVariable("id") Long id) { public ApiResult frozen(@PathVariable("id") Long id, HttpServletRequest request) {
//return ApiResult.ok(this.service.frozen(id)); String portUserName = request.getHeader("portUserName");
return null; DxBaselineVO frozen = null;
try {
frozen = DxBaselineService.frozen(id, portUserName);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getCause().getLocalizedMessage(), e);
}
return ApiResult.ok(frozen);
} }
//@ApiOperation("基线解冻") //@ApiOperation("基线解冻")
@PostMapping({"/unFrozen/{id}"}) @PostMapping({"/unFrozen/{id}"})
public ApiResult unFrozen(@PathVariable("id") Long id) { public ApiResult unFrozen(@PathVariable("id") Long id, HttpServletRequest request) {
//return ApiResult.ok(this.service.unFrozen(id)); String portUserName = request.getHeader("portUserName");
return null; DxBaselineVO frozen = null;
try {
frozen = DxBaselineService.unFrozen(id, portUserName);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getCause().getLocalizedMessage(), e);
}
return ApiResult.ok(frozen);
} }
//保存基线 //保存基线
@PostMapping({"recursion"}) @PostMapping({"recursion"})
......
...@@ -4,34 +4,30 @@ import com.yonde.baseline.vo.DxBaselineMemberVO; ...@@ -4,34 +4,30 @@ import com.yonde.baseline.vo.DxBaselineMemberVO;
import com.yonde.baseline.vo.DxBaselineVO; import com.yonde.baseline.vo.DxBaselineVO;
import com.yonde.common.*; import com.yonde.common.*;
import com.yonde.context.vo.DxContextVO; import com.yonde.context.vo.DxContextVO;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import wt.doc.WTDocument; import org.apache.log4j.Logger;
import wt.epm.EPMDocument;
import wt.fc.IdentityHelper; import wt.fc.IdentityHelper;
import wt.fc.Persistable; import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.fc.WTObject; import wt.fc.WTObject;
import wt.fc.collections.WTCollection; import wt.fc.collections.WTCollection;
import wt.fc.collections.WTHashSet; import wt.fc.collections.WTHashSet;
import wt.inf.container.WTContainer; import wt.inf.container.WTContainer;
import wt.locks.LockHelper;
import wt.log4j.LogR;
import wt.method.RemoteAccess; import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer; import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.pom.Transaction; import wt.pom.Transaction;
import wt.session.SessionServerHelper; import wt.session.SessionServerHelper;
import wt.util.WTException; import wt.util.WTException;
import wt.vc.baseline.BaselineHelper; import wt.vc.baseline.BaselineHelper;
import wt.vc.baseline.Baselineable;
import wt.vc.baseline.ManagedBaseline; import wt.vc.baseline.ManagedBaseline;
import wt.vc.baseline.ManagedBaselineIdentity; import wt.vc.baseline.ManagedBaselineIdentity;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector;
public class DxBaselineService implements RemoteAccess { public class DxBaselineService implements RemoteAccess {
private static final Logger log = LogR.getLogger(DxBaselineService.class.getName());
public static DxBaselineVO createBaseline(DxBaselineVO baselineVO, String userName) throws Exception { public static DxBaselineVO createBaseline(DxBaselineVO baselineVO, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) { if (!RemoteMethodServer.ServerFlag) {
return (DxBaselineVO) RemoteMethodServer.getDefault().invoke("createBaseline", DxBaselineService.class.getName(), null, return (DxBaselineVO) RemoteMethodServer.getDefault().invoke("createBaseline", DxBaselineService.class.getName(), null,
...@@ -70,7 +66,7 @@ public class DxBaselineService implements RemoteAccess { ...@@ -70,7 +66,7 @@ public class DxBaselineService implements RemoteAccess {
if (ObjectsUtil.nonNull(baselineVO.getDynamicAttrs())) { if (ObjectsUtil.nonNull(baselineVO.getDynamicAttrs())) {
IBAUtil.forceSetIBAValues(baseline, baselineVO.getDynamicAttrs()); IBAUtil.forceSetIBAValues(baseline, baselineVO.getDynamicAttrs());
} }
dxBaselineVO = new DxBaselineVO(baseline); dxBaselineVO = new DxBaselineVO(baseline, false);
ts.commit(); ts.commit();
ts = null; ts = null;
} finally { } finally {
...@@ -109,19 +105,21 @@ public class DxBaselineService implements RemoteAccess { ...@@ -109,19 +105,21 @@ public class DxBaselineService implements RemoteAccess {
ManagedBaselineIdentity identificationObject = (ManagedBaselineIdentity)baseline.getIdentificationObject(); ManagedBaselineIdentity identificationObject = (ManagedBaselineIdentity)baseline.getIdentificationObject();
identificationObject.setName(baselineVO.getName()); identificationObject.setName(baselineVO.getName());
IdentityHelper.service.changeIdentity(baseline, identificationObject); // 重命名名称 IdentityHelper.service.changeIdentity(baseline, identificationObject); // 重命名名称
dxBaselineVO = new DxBaselineVO(baseline); dxBaselineVO = new DxBaselineVO(baseline, false);
//更新基线对象 //更新基线对象
QueryResult items = BaselineHelper.service.getBaselineItems(baseline); /* QueryResult items = BaselineHelper.service.getBaselineItems(baseline);
Vector vector = items.getObjectVector().getVector(); Vector vector = items.getObjectVector().getVector();
//删除基线对象 BaselineHelper.service.removeFromBaseline(vector,baseline);*/
BaselineHelper.service.removeFromBaseline( vector,baseline);
List<DxBaselineMemberVO> baselineMembers = baselineVO.getBaselineMembers(); List<DxBaselineMemberVO> baselineMembers = baselineVO.getBaselineMembers();
if (CollectionUtils.isNotEmpty(baselineMembers)) { if (CollectionUtils.isNotEmpty(baselineMembers)) {
WTCollection collectDocuments = new WTHashSet(); WTCollection collectDocuments = new WTHashSet();
for (DxBaselineMemberVO member : baselineMembers) { for (DxBaselineMemberVO member : baselineMembers) {
Long id = member.getTarget().getId(); Long id = member.getTarget().getId();
WTObject wtObjectById = RfUtil.getWTObjectById(id); WTObject wtObjectById = RfUtil.getWTObjectById(id);
if ("REMOVE".equalsIgnoreCase(member.getOperator())) {
BaselineHelper.service.removeFromBaseline((Baselineable) wtObjectById, baseline);
continue;
}
collectDocuments.add(wtObjectById); collectDocuments.add(wtObjectById);
} }
BaselineHelper.service.addToBaseline(collectDocuments, baseline); BaselineHelper.service.addToBaseline(collectDocuments, baseline);
...@@ -141,7 +139,35 @@ public class DxBaselineService implements RemoteAccess { ...@@ -141,7 +139,35 @@ public class DxBaselineService implements RemoteAccess {
return dxBaselineVO; return dxBaselineVO;
} }
public static void buildDxBaselineMembers(DxBaselineVO baselineVO) throws Exception { public static DxBaselineVO frozen(Long id, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxBaselineVO) RemoteMethodServer.getDefault().invoke("frozen", DxBaselineService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, userName});
}
CommonUtil.initSessionContext(userName);
ManagedBaseline baseline = (ManagedBaseline) RfUtil.getWTObjectById(id);
baseline = (ManagedBaseline) LockHelper.assignLock(baseline, null, "后台锁定");
baseline = (ManagedBaseline) PersistenceHelper.manager.save(baseline);
DxBaselineVO dxBaselineVO = new DxBaselineVO(baseline, false);
return dxBaselineVO;
}
public static DxBaselineVO unFrozen(Long id, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxBaselineVO) RemoteMethodServer.getDefault().invoke("unFrozen", DxBaselineService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, userName});
}
CommonUtil.initSessionContext(userName);
ManagedBaseline baseline = (ManagedBaseline) RfUtil.getWTObjectById(id);
baseline = (ManagedBaseline) LockHelper.releaseLock(baseline);
baseline = (ManagedBaseline) PersistenceHelper.manager.save(baseline);
DxBaselineVO dxBaselineVO = new DxBaselineVO(baseline, false);
return dxBaselineVO;
}
/* public static void buildDxBaselineMembers(DxBaselineVO baselineVO) throws Exception {
Long id = baselineVO.getId(); Long id = baselineVO.getId();
WTObject wtObjectById = RfUtil.getWTObjectById(id); WTObject wtObjectById = RfUtil.getWTObjectById(id);
if (ObjectsUtil.nonNull(wtObjectById)) { if (ObjectsUtil.nonNull(wtObjectById)) {
...@@ -149,12 +175,13 @@ public class DxBaselineService implements RemoteAccess { ...@@ -149,12 +175,13 @@ public class DxBaselineService implements RemoteAccess {
DxBaselineVO dxBaselineVO = buildDxBaseline(baseline); DxBaselineVO dxBaselineVO = buildDxBaseline(baseline);
baselineVO.setBaselineMembers(dxBaselineVO.getBaselineMembers()); baselineVO.setBaselineMembers(dxBaselineVO.getBaselineMembers());
} }
} }*/
public static DxBaselineVO buildDxBaseline(ManagedBaseline baseline) throws Exception { /*public static DxBaselineVO buildDxBaseline(ManagedBaseline baseline) throws Exception {
DxBaselineVO dxBaselineVO = new DxBaselineVO(baseline); DxBaselineVO dxBaselineVO = new DxBaselineVO(baseline, false);
QueryResult baselineItems = BaselineHelper.service.getBaselineItems(baseline); QueryResult baselineItems = BaselineHelper.service.getBaselineItems(baseline);
List<DxBaselineMemberVO> memberVOList = new ArrayList<DxBaselineMemberVO>(); List<DxBaselineMemberVO> memberVOList = new ArrayList<DxBaselineMemberVO>();
log.error("===buildDxBaseline 1 ===" + baselineItems.size());
while (baselineItems.hasMoreElements()) { while (baselineItems.hasMoreElements()) {
Persistable obj = (Persistable) baselineItems.nextElement(); Persistable obj = (Persistable) baselineItems.nextElement();
if (obj instanceof WTPart) { if (obj instanceof WTPart) {
...@@ -173,7 +200,8 @@ public class DxBaselineService implements RemoteAccess { ...@@ -173,7 +200,8 @@ public class DxBaselineService implements RemoteAccess {
//TODO //TODO
} }
} }
log.error("===buildDxBaseline===" + memberVOList.size());
dxBaselineVO.setBaselineMembers(memberVOList); dxBaselineVO.setBaselineMembers(memberVOList);
return dxBaselineVO; return dxBaselineVO;
} }*/
} }
...@@ -5,34 +5,40 @@ import com.yonde.basedata.vo.RevisionControlledVO; ...@@ -5,34 +5,40 @@ import com.yonde.basedata.vo.RevisionControlledVO;
import java.io.Serializable; import java.io.Serializable;
public class DxBaselineMemberVO implements Serializable { public class DxBaselineMemberVO implements Serializable {
private Long id;
private DxBaselineVO source;
private RevisionControlledVO target; private RevisionControlledVO target;
private Long sourceId; private Long sourceId;
private String sourceIdType; private String sourceIdType;
private Long targetId; private Long targetId;
private String targetIdType; private String targetIdType;
private String operator;
public DxBaselineMemberVO() { public DxBaselineMemberVO() {
} }
public DxBaselineMemberVO(DxBaselineVO source, RevisionControlledVO target) { public DxBaselineMemberVO(DxBaselineVO source, RevisionControlledVO target) {
this.source = source;
this.sourceId = source.getId(); this.sourceId = source.getId();
this.sourceIdType = source.getSubTypeName(); this.sourceIdType = source.getSubTypeName();
this.target = target; this.target = target;
this.targetId = target.getId(); this.targetId = target.getId();
this.targetIdType = target.getSubTypeName(); this.targetIdType = target.getSubTypeName();
this.id = targetId;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
} }
public DxBaselineVO getSource() { public Long getId() {
return source; return id;
} }
public void setSource(DxBaselineVO source) { public void setId(Long id) {
this.source = source; this.id = id;
} }
public RevisionControlledVO getTarget() { public RevisionControlledVO getTarget() {
......
...@@ -6,14 +6,24 @@ import com.yonde.basedata.vo.IdVO; ...@@ -6,14 +6,24 @@ import com.yonde.basedata.vo.IdVO;
import com.yonde.common.IBAHelper; import com.yonde.common.IBAHelper;
import com.yonde.common.ObjectsUtil; import com.yonde.common.ObjectsUtil;
import com.yonde.context.vo.DxContextVO; import com.yonde.context.vo.DxContextVO;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO;
import wt.doc.WTDocument;
import wt.epm.EPMDocument;
import wt.fc.Persistable;
import wt.fc.QueryResult;
import wt.locks.LockHelper;
import wt.org.WTOrganization; import wt.org.WTOrganization;
import wt.part.WTPart;
import wt.type.ClientTypedUtility; import wt.type.ClientTypedUtility;
import wt.util.WTException; import wt.util.WTException;
import wt.vc.baseline.BaselineHelper;
import wt.vc.baseline.ManagedBaseline; import wt.vc.baseline.ManagedBaseline;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
...@@ -31,15 +41,17 @@ public class DxBaselineVO extends IdVO implements Serializable { ...@@ -31,15 +41,17 @@ public class DxBaselineVO extends IdVO implements Serializable {
private DxOrganizationVO dxOrganization; private DxOrganizationVO dxOrganization;
private Long dxOrganizationId; private Long dxOrganizationId;
private String dxOrganizationIdType; private String dxOrganizationIdType;
private Long masterId;
public DxBaselineVO() { public DxBaselineVO() {
} }
public DxBaselineVO(ManagedBaseline baseline) throws WTException, RemoteException, InvocationTargetException { public DxBaselineVO(ManagedBaseline baseline, boolean needMembers) throws Exception {
super(baseline); super(baseline);
this.versionId = this.id; this.versionId = this.id;
this.masterId = this.id;
this.state = baseline.getState().getState().toString(); this.state = baseline.getState().getState().toString();
this.frozenState = baseline.isDirty(); this.frozenState = LockHelper.isLocked(baseline);
this.name = baseline.getName(); this.name = baseline.getName();
this.number = baseline.getNumber(); this.number = baseline.getNumber();
// 获取基线对象 // 获取基线对象
...@@ -53,6 +65,29 @@ public class DxBaselineVO extends IdVO implements Serializable { ...@@ -53,6 +65,29 @@ public class DxBaselineVO extends IdVO implements Serializable {
this.dynamicAttrs = IBAHelper.getAllIBAValues(baseline); this.dynamicAttrs = IBAHelper.getAllIBAValues(baseline);
this.subTypeName = "DxBaseline";//TODO 要映射 this.subTypeName = "DxBaseline";//TODO 要映射
this.subTypeDisplayName = ClientTypedUtility.getLocalizedTypeName(baseline, Locale.SIMPLIFIED_CHINESE); this.subTypeDisplayName = ClientTypedUtility.getLocalizedTypeName(baseline, Locale.SIMPLIFIED_CHINESE);
if (needMembers) {
QueryResult baselineItems = BaselineHelper.service.getBaselineItems(baseline);
List<DxBaselineMemberVO> memberVOList = new ArrayList<DxBaselineMemberVO>();
while (baselineItems.hasMoreElements()) {
Persistable obj = (Persistable) baselineItems.nextElement();
if (obj instanceof WTPart) {
DxPartVO dxPartVO = new DxPartVO((WTPart) obj);
DxBaselineMemberVO memberVO = new DxBaselineMemberVO(this, dxPartVO);
memberVOList.add(memberVO);
continue;
}
if (obj instanceof WTDocument) {
DxDocumentVO dxDocumentVO = new DxDocumentVO((WTDocument) obj);
DxBaselineMemberVO memberVO = new DxBaselineMemberVO(this, dxDocumentVO);
memberVOList.add(memberVO);
continue;
}
if (obj instanceof EPMDocument) {
//TODO
}
}
this.setBaselineMembers(memberVOList);
}
} }
public List<DxBaselineMemberVO> getBaselineMembers() { public List<DxBaselineMemberVO> getBaselineMembers() {
...@@ -63,6 +98,14 @@ public class DxBaselineVO extends IdVO implements Serializable { ...@@ -63,6 +98,14 @@ public class DxBaselineVO extends IdVO implements Serializable {
this.baselineMembers = baselineMembers; this.baselineMembers = baselineMembers;
} }
public Long getMasterId() {
return masterId;
}
public void setMasterId(Long masterId) {
this.masterId = masterId;
}
public Boolean getFrozenState() { public Boolean getFrozenState() {
return frozenState; return frozenState;
} }
......
package com.yonde.common; package com.yonde.common;
import com.yonde.contants.Global;
import wt.fc.IdentityHelper; import wt.fc.IdentityHelper;
import wt.fc.PersistenceHelper; import wt.fc.PersistenceHelper;
import wt.folder.Folder; import wt.folder.Folder;
...@@ -50,7 +51,7 @@ public class BaseLineUtil { ...@@ -50,7 +51,7 @@ public class BaseLineUtil {
if (ObjectsUtil.isNull(baselineType)) { if (ObjectsUtil.isNull(baselineType)) {
baselineType = "wt.vc.baseline.ManagedBaseline"; baselineType = "wt.vc.baseline.ManagedBaseline";
} else { } else {
baselineType = CommonUtil.buildTypeKey(Global.PMD_DOMAIN, baselineType, ManagedBaseline.class);
} }
TypeDefinitionReference typeDef = TypedUtility.getTypeDefinitionReference(baselineType); TypeDefinitionReference typeDef = TypedUtility.getTypeDefinitionReference(baselineType);
if(typeDef == null) throw new WTException("没有此类型:"+baselineType); if(typeDef == null) throw new WTException("没有此类型:"+baselineType);
......
...@@ -838,4 +838,12 @@ public class CommonUtil implements RemoteAccess { ...@@ -838,4 +838,12 @@ public class CommonUtil implements RemoteAccess {
} }
return folder; return folder;
} }
public static String buildTypeKey(String domain, String key, Class<? extends WTObject> cls) {
String typeName = cls.getName() + "|" + key;
if (StringUtils.isNotEmpty(domain)) {
typeName = cls.getName() + "|" + domain + "." +key;
}
return typeName;
}
} }
...@@ -1045,7 +1045,9 @@ public class DocUtil implements RemoteAccess, Serializable { ...@@ -1045,7 +1045,9 @@ public class DocUtil implements RemoteAccess, Serializable {
AttributeDefDefaultView addv = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( AttributeDefDefaultView addv = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(
ibaName); ibaName);
if (addv == null) { if (addv == null) {
throw new IBADefinitionException("No IBA Definition:" + ibaName); logger.error("No IBA Definition:" + ibaName);
//throw new IBADefinitionException("No IBA Definition:" + ibaName);
return null;
} }
long ibaDefId = addv.getObjectID().getId(); long ibaDefId = addv.getObjectID().getId();
QuerySpec qs = new QuerySpec(); QuerySpec qs = new QuerySpec();
......
package com.yonde.common; package com.yonde.common;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.search.SearchItem; import com.yonde.basedata.search.SearchItem;
import com.yonde.basedata.search.SearchItems; import com.yonde.basedata.search.SearchItems;
import com.yonde.basedata.search.SearchOperatorEnumUtil; import com.yonde.basedata.search.SearchOperatorEnumUtil;
import com.yonde.basedata.search.SearchQueryCondition; import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.baseline.service.DxBaselineService;
import com.yonde.baseline.vo.DxBaselineVO; import com.yonde.baseline.vo.DxBaselineVO;
import com.yonde.change.service.DXChangeOrderService; import com.yonde.change.service.DXChangeOrderService;
import com.yonde.change.vo.ecn.DxChangeNoticeVo; import com.yonde.change.vo.ecn.DxChangeNoticeVo;
import com.yonde.change.vo.ecr.DxChangeRequestVo; import com.yonde.change.vo.ecr.DxChangeRequestVo;
import com.yonde.change.vo.pr.DxProblemReportVo; import com.yonde.change.vo.pr.DxProblemReportVo;
import com.yonde.contants.Global;
import com.yonde.doc.vo.DxDocumentVO; import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO; import com.yonde.part.vo.DxPartVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import wt.change2.WTChangeIssue; import wt.change2.WTChangeIssue;
import wt.change2.WTChangeOrder2; import wt.change2.WTChangeOrder2;
import wt.change2.WTChangeRequest2; import wt.change2.WTChangeRequest2;
import wt.doc.WTDocument; import wt.doc.WTDocument;
import wt.fc.*; import wt.fc.*;
import wt.folder.Folder;
import wt.folder.Foldered;
import wt.inf.container.WTContained;
import wt.inf.container.WTContainer;
import wt.log4j.LogR; import wt.log4j.LogR;
import wt.method.RemoteAccess; import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart; import wt.part.WTPart;
import wt.pds.StatementSpec;
import wt.query.*; import wt.query.*;
import wt.session.SessionServerHelper; import wt.session.SessionServerHelper;
import wt.type.TypeDefinitionForeignKey;
import wt.type.TypeDefinitionReference;
import wt.type.TypedUtility;
import wt.util.WTAttributeNameIfc; import wt.util.WTAttributeNameIfc;
import wt.util.WTException; import wt.util.WTException;
import wt.vc.Iterated; import wt.vc.Iterated;
...@@ -41,7 +43,6 @@ import wt.vc.wip.WorkInProgressState; ...@@ -41,7 +43,6 @@ import wt.vc.wip.WorkInProgressState;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -49,39 +50,6 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -49,39 +50,6 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
private static Logger logger = LogR.getLogger(DxSearchUtil.class.getName()); private static Logger logger = LogR.getLogger(DxSearchUtil.class.getName());
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Deprecated
public static DxPageImpl findByConfigSpec (SearchQueryCondition searchQueryCondition) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPageImpl) RemoteMethodServer.getDefault().invoke("findByConfigSpecSelect", DxSearchUtil.class.getName(), null,
new Class[] { SearchQueryCondition.class},
new Object[] { searchQueryCondition});
}
logger.error("searchCondition===111" + searchQueryCondition.toString());
boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
List partList;
List<String> indices = searchQueryCondition.getIndices();
try {
SearchItems searchItems = searchQueryCondition.getSearchItems();
if (ObjectsUtil.isNull(searchItems)) {
searchItems = searchQueryCondition.getSearchVersion().getSearchItems();
}
QuerySpec querySpec = DxSearchUtil.buildQuerySpec(searchItems, WTPart.class);
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) querySpec);
partList = new ArrayList<DxPartVO>();
while (qr.hasMoreElements()) {
WTObject o = (WTObject) qr.nextElement();
if (o instanceof WTPart) {
buildQueryResult(o, partList, indices);
}
}
} finally {
SessionServerHelper.manager.setAccessEnforced(enforce);
}
long total = CollectionUtils.size(partList);
PageImpl ts = new PageImpl(partList, new PageRequest(searchQueryCondition.getPageFrom(), searchQueryCondition.getPageSize()), total);
return DxPageImpl.fromPage(ts);
}
/** /**
* 通用查询接口 * 通用查询接口
* @param searchQueryCondition * @param searchQueryCondition
...@@ -92,9 +60,9 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -92,9 +60,9 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
CommonUtil.initSessionContext(null); CommonUtil.initSessionContext(null);
boolean enforce = SessionServerHelper.manager.setAccessEnforced(false); boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
List<String> indices = searchQueryCondition.getIndices(); List<String> indices = searchQueryCondition.getIndices();
Class cls = WTPart.class; Class cls = SearchOperatorEnumUtil.typeMap.get(searchQueryCondition.getName());
if (StringUtils.isNotEmpty(searchQueryCondition.getName())) { if (ObjectsUtil.isNull(cls)) {
cls = SearchOperatorEnumUtil.typeMap.get(searchQueryCondition.getName()); throw new WTException("搜索类型不存在!");
} }
try { try {
//合并查询条件 //合并查询条件
...@@ -137,7 +105,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -137,7 +105,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
bpqs.setPrimaryStatement(querySpec); bpqs.setPrimaryStatement(querySpec);
logger.error("pageFrom====" + pageFrom*pageSize); logger.error("pageFrom====" + pageFrom*pageSize);
logger.error("pageSize====" + pageSize); logger.error("pageSize====" + pageSize);
bpqs.setOffset(pageFrom*pageSize); bpqs.setOffset(pageFrom * pageSize);
bpqs.setRange(pageSize); bpqs.setRange(pageSize);
bpqs.setBackgroundThreadEnabled(false); bpqs.setBackgroundThreadEnabled(false);
bpqs.setLimitModeEnabled(true); bpqs.setLimitModeEnabled(true);
...@@ -152,10 +120,10 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -152,10 +120,10 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
* 生成反馈结果 * 生成反馈结果
* @param o * @param o
* @param objList * @param objList
* @param indices * @param searchQueryCondition
* @throws Exception * @throws Exception
*/ */
public static void buildQueryResult(WTObject o, List objList, List<String> indices) throws Exception { public static void buildQueryResult(WTObject o, List objList, SearchQueryCondition searchQueryCondition) throws Exception {
long id = PersistenceHelper.getObjectIdentifier(o).getId(); long id = PersistenceHelper.getObjectIdentifier(o).getId();
if (o instanceof WTPart) { if (o instanceof WTPart) {
WTPart wtPart = (WTPart) o; WTPart wtPart = (WTPart) o;
...@@ -172,7 +140,15 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -172,7 +140,15 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
if (o instanceof ManagedBaseline) { if (o instanceof ManagedBaseline) {
//基线 //基线
ManagedBaseline baseline = (ManagedBaseline) o; ManagedBaseline baseline = (ManagedBaseline) o;
DxBaselineVO baselineVO = DxBaselineService.buildDxBaseline(baseline); boolean needMember = false;
List<SearchQueryCondition> openProps = searchQueryCondition.getOpenProps();
if (CollectionUtils.isNotEmpty(openProps)) {
SearchQueryCondition condition = openProps.get(0);
if ("baselineMembers".equalsIgnoreCase(condition.getName())) {
needMember = true;
}
}
DxBaselineVO baselineVO = new DxBaselineVO(baseline, needMember);
objList.add(baselineVO); objList.add(baselineVO);
return; return;
} }
...@@ -251,13 +227,45 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -251,13 +227,45 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
for (SearchItem item : items) { for (SearchItem item : items) {
logger.error("item===111" + item.toString()); logger.error("item===111" + item.toString());
String fieldName = item.fieldName; String fieldName = item.fieldName;
/* if (fieldName.equals("masterId")) {
return null;
}*/
// TODO fieldName.equals(SearchOperatorEnumUtil.DX_ID)||latest // TODO fieldName.equals(SearchOperatorEnumUtil.DX_ID)||latest
if (fieldName.equals("checkOuted") || fieldName.equals("creatorId")|| fieldName.equals("latest")) { if (fieldName.equals("checkOuted") || fieldName.equals("creatorId")|| fieldName.equals("latest")) {
continue; continue;
} }
//子类型
if (fieldName.equals(SearchOperatorEnumUtil.DX_SUBTYPE_NAME)) {
// TODO 域名待确认
String typeName = CommonUtil.buildTypeKey(Global.PMD_DOMAIN, (String)item.value, clazz);
TypeDefinitionReference tdr = TypedUtility.getTypeDefinitionReference(typeName);
if (ObjectsUtil.nonNull(tdr)) {
addQuerySpecOp(querySpec, operator);
SearchCondition typeDefinitionCondition = new SearchCondition(WTDocument.class,
WTDocument.TYPE_DEFINITION_REFERENCE + "." + TypeDefinitionReference.KEY + "." + TypeDefinitionForeignKey.BRANCH_ID,
SearchCondition.EQUAL, tdr.getKey().getBranchId());
querySpec.appendWhere(typeDefinitionCondition, new int[]{0});
}
continue;
}
//TODO 产品 存储库
if (fieldName.equals(SearchOperatorEnumUtil.DX_CONTEXT_NAME)) {
WTContainer container = ContainerUtil.getContainerByName((String)item.value);
if (container != null) {
addQuerySpecOp(querySpec, operator);
SearchCondition sc = new SearchCondition(WTContained.class, WTContained.CONTAINER_ID, SearchCondition.EQUAL, PersistenceHelper.getObjectIdentifier(container).getId());
querySpec.appendWhere(sc, new int[]{0});
}
continue;
}
//TODO 文件夹
if (fieldName.equals(SearchOperatorEnumUtil.DX_FOLDER_ID)) {
Folder folderByOid = (Folder) RfUtil.getWTObjectByOid("OR:wt.folder.SubFolder:" + item.value);
if (ObjectsUtil.nonNull(folderByOid)) {
addQuerySpecOp(querySpec, operator);
SearchCondition sc = new SearchCondition(clazz, Foldered.FOLDERING_INFO + "." + WTAttributeNameIfc.REF_OBJECT_ID,
SearchCondition.EQUAL, PersistenceHelper.getObjectIdentifier(folderByOid).getId());
querySpec.appendWhere(sc, new int[]{0});
}
continue;
}
//视图 //视图
if (fieldName.equals(SearchOperatorEnumUtil.DX_VIEWID)) { if (fieldName.equals(SearchOperatorEnumUtil.DX_VIEWID)) {
String viewName = SearchOperatorEnumUtil.viewMap.get(String.valueOf(item.value)); String viewName = SearchOperatorEnumUtil.viewMap.get(String.valueOf(item.value));
...@@ -288,13 +296,16 @@ public class DxSearchUtil implements RemoteAccess, Serializable { ...@@ -288,13 +296,16 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
continue; continue;
} }
// 软属性子查询 // 软属性子查询
addQuerySpecOp(querySpec, operator);
SubSelectExpression subSelect = DocUtil.getStringIBAQuery(fieldName, String.valueOf(item.value), "B"); SubSelectExpression subSelect = DocUtil.getStringIBAQuery(fieldName, String.valueOf(item.value), "B");
if (ObjectsUtil.nonNull(subSelect)) {
addQuerySpecOp(querySpec, operator);
SearchCondition sc = new SearchCondition( SearchCondition sc = new SearchCondition(
new ClassAttribute(clazz, Persistable.PERSIST_INFO + "." + PersistInfo.OBJECT_IDENTIFIER + "." + ObjectIdentifier.ID), SearchCondition.IN, new ClassAttribute(clazz, Persistable.PERSIST_INFO + "." + PersistInfo.OBJECT_IDENTIFIER + "." + ObjectIdentifier.ID), SearchCondition.IN,
subSelect); subSelect);
querySpec.appendWhere(sc, new int[]{0}); querySpec.appendWhere(sc, new int[]{0});
} }
}
} }
/** /**
......
package com.yonde.contants;
public interface Global {
String PMD_DOMAIN = "com.yonde";
}
package com.yonde.context.uitls;
import com.yonde.common.RfUtil;
import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.folder.Cabinet;
import wt.folder.Folder;
import wt.folder.FolderHelper;
import wt.inf.container.WTContainer;
import wt.inf.library.WTLibrary;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.pdmlink.PDMLinkProduct;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ContainerUtil implements RemoteAccess {
private static String CLASSNAME = ContainerUtil.class.getName();
public static WTContainer getContainerByName(String containerName) throws WTException {
if (!RemoteMethodServer.ServerFlag) {
try {
return (WTContainer) RemoteMethodServer.getDefault().invoke("getContainerByName", CLASSNAME, null,
new Class[]{String.class}, new Object[]{containerName});
} catch (Exception e) {
e.printStackTrace();
throw new WTException(e, e.getLocalizedMessage());
}
} else {
boolean access = SessionServerHelper.manager.setAccessEnforced(false);
try {
QuerySpec qs = new QuerySpec(WTContainer.class);
SearchCondition sc = new SearchCondition(WTContainer.class, WTContainer.NAME, SearchCondition.EQUAL, containerName);
qs.appendSearchCondition(sc);
QueryResult qr = PersistenceHelper.manager.find(qs);
if (qr.hasMoreElements()) {
return (WTContainer) qr.nextElement();
}
return null;
} finally {
SessionServerHelper.manager.setAccessEnforced(access);
}
}
}
public List<Folder> getAllSubFolder(Folder parentFolder)
throws WTException {
List<Folder> resultList = new ArrayList<Folder>();
QueryResult result = FolderHelper.service.findSubFolders(parentFolder);
while (result.hasMoreElements()) {
Folder subFolder = (Folder) result.nextElement();
resultList.add(subFolder);
//ProFolder node = toEntity((WTObject) subFolder, ProFolder.class);
/* if (node != null) {
if (parentFolder != null) {
node.setSuperior(
String.valueOf(parentFolder.getPersistInfo().getObjectIdentifier().getId()));
}
treeNodes.add(node);
treeNodeDocs.add(subFolder);
}
getAllsubFolder(treeNodes, treeNodeDocs, subFolder);*/
}
return resultList;
}
public Map<String, Object> getProjectFolderByFilter(String productOid, String type) throws Exception {
//根文件夹
Cabinet cabinet = null;
Persistable container = RfUtil.getWTObjectByOid(productOid);
if (container instanceof PDMLinkProduct) {
cabinet = ((PDMLinkProduct) container).getDefaultCabinet();
} else if (container instanceof WTLibrary) {
cabinet = ((WTLibrary) container).getDefaultCabinet();
} else {
System.err.println("==> treeNodeDocs container : " + container);
}
if (cabinet == null) {
return null;
}
List<Folder> allSubFolder = getAllSubFolder(cabinet);
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment