Commit 6acb7d72 authored by shyWang's avatar shyWang

PDM前端改造

初始提交
parent 3008305a
package com.yonde.basedata.controller;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.BaseSearchCondition;
import com.yonde.basedata.search.SearchItems;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.service.BaseSearchService;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.ObjectsUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
public abstract class AbstractBaseController<V extends IdVO, S extends BaseSearchService> {
protected abstract S getService();
//S getService();
@PostMapping({"recursion"})
ApiResult recursionObj(@RequestBody V entity) {
return ApiResult.ok(this.getService().saveRecursion(entity));
}
@PostMapping({"/search"})
//@ApiOperation("查询所有")
ApiResult<DxPageImpl<V>> findAll(@RequestBody SearchQueryCondition searchQueryCondition, @RequestParam(required = false) BaseSearchCondition permSearchParams) {
SearchItems searchItems = searchQueryCondition.getSearchItems();
if (ObjectsUtil.nonNull(searchItems)) {
SearchItems permSearchItems = this.getPermSearchItems(permSearchParams);
searchQueryCondition.getSearchItems().addChild(permSearchItems);
}
return ApiResult.ok(this.getService().search(searchQueryCondition));
}
SearchItems getPermSearchItems(BaseSearchCondition permSearchParams) {
SearchItems searchItems = new SearchItems();
searchItems.setOperator(SearchItems.BooleanOperator.AND);
if (ObjectsUtil.nonNull(permSearchParams) && ObjectsUtil.nonNull(permSearchParams.getSearchItems())) {
searchItems = permSearchParams.getSearchItems();
}
return searchItems;
}
//TODO 其他基础接口
}
package com.yonde.basedata.data;
public interface DxEnumData {
String getCode();
String getValue();
}
package com.yonde.basedata.data;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class DxPageImpl<T> {
private List<T> content;
private int number;
private int size;
private long totalElements;
private int totalPages;
/* public DxPageImpl<T> convertToPage() {
return new DxPageImpl(this.content, PageRequest.of(this.number, this.size), this.totalElements);
}*/
public static <T> DxPageImpl<T> fromPage(DxPageImpl<T> page) {
DxPageImpl<T> dxPage = (DxPageImpl<T>) builder().number(page.getNumber()).size(page.getSize()).totalElements(page.getTotalElements()).totalPages(page.getTotalPages()).build();
if (CollectionUtils.size(page.getContent()) == 0) {
dxPage.setContent(new ArrayList<T>());
} else {
dxPage.setContent(new ArrayList<T>(page.getContent()));
}
return dxPage;
}
public static <T> DxPageImpl.DxPageImplBuilder<T> builder() {
return new DxPageImpl.DxPageImplBuilder();
}
public List<T> getContent() {
return this.content;
}
public int getNumber() {
return this.number;
}
public int getSize() {
return this.size;
}
public long getTotalElements() {
return this.totalElements;
}
public int getTotalPages() {
return this.totalPages;
}
public void setContent(List<T> content) {
this.content = content;
}
public void setNumber(int number) {
this.number = number;
}
public void setSize(int size) {
this.size = size;
}
public void setTotalElements(long totalElements) {
this.totalElements = totalElements;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public String toString() {
return "DxPageImpl(content=" + this.getContent() + ", number=" + this.getNumber() + ", size=" + this.getSize() + ", totalElements=" + this.getTotalElements() + ", totalPages=" + this.getTotalPages() + ")";
}
public DxPageImpl(List<T> content, int number, int size, long totalElements, int totalPages) {
this.content = content;
this.number = number;
this.size = size;
this.totalElements = totalElements;
this.totalPages = totalPages;
}
public DxPageImpl() {
}
public static class DxPageImplBuilder<T> {
private ArrayList<T> content;
private int number;
private int size;
private long totalElements;
private int totalPages;
DxPageImplBuilder() {
}
public DxPageImpl.DxPageImplBuilder<T> contentSingle(T contentSingle) {
if (this.content == null) {
this.content = new ArrayList();
}
this.content.add(contentSingle);
return this;
}
public DxPageImpl.DxPageImplBuilder<T> content(Collection<? extends T> content) {
if (content == null) {
throw new NullPointerException("content cannot be null");
} else {
if (this.content == null) {
this.content = new ArrayList();
}
this.content.addAll(content);
return this;
}
}
public DxPageImpl.DxPageImplBuilder<T> clearContent() {
if (this.content != null) {
this.content.clear();
}
return this;
}
public DxPageImpl.DxPageImplBuilder<T> number(int number) {
this.number = number;
return this;
}
public DxPageImpl.DxPageImplBuilder<T> size(int size) {
this.size = size;
return this;
}
public DxPageImpl.DxPageImplBuilder<T> totalElements(long totalElements) {
this.totalElements = totalElements;
return this;
}
public DxPageImpl.DxPageImplBuilder<T> totalPages(int totalPages) {
this.totalPages = totalPages;
return this;
}
public DxPageImpl<T> build() {
List content;
switch(this.content == null ? 0 : this.content.size()) {
case 0:
content = Collections.emptyList();
break;
case 1:
content = Collections.singletonList(this.content.get(0));
break;
default:
content = Collections.unmodifiableList(new ArrayList(this.content));
}
return new DxPageImpl(content, this.number, this.size, this.totalElements, this.totalPages);
}
public String toString() {
return "DxPageImpl.DxPageImplBuilder(content=" + this.content + ", number=" + this.number + ", size=" + this.size + ", totalElements=" + this.totalElements + ", totalPages=" + this.totalPages + ")";
}
}
}
package com.yonde.basedata.data;
public enum Logical {
AND,
OR;
private Logical() {
}
}
package com.yonde.basedata.entity.api;
import com.yonde.basedata.data.DxEnumData;
import com.yonde.basedata.exception.DxBusinessException;
import com.yonde.basedata.exception.DxErrorCodeData;
import org.apache.commons.lang.StringUtils;
import org.springframework.core.NestedExceptionUtils;
public class ApiResult<T> {
public static final String SUCCESS = "0";
private String code;
private String message;
private T items;
private Exception error;
@Deprecated
public ApiResult() {
this.code = "0";
}
/** @deprecated */
@Deprecated
public ApiResult(T obj) {
this();
this.items = obj;
}
/** @deprecated */
@Deprecated
public ApiResult(String code, T obj) {
this.code = code;
this.items = obj;
}
/** @deprecated */
@Deprecated
public ApiResult(String code, String message) {
this.code = code;
this.message = message;
}
/** @deprecated */
@Deprecated
public ApiResult(boolean result, String message) {
if (!result) {
this.code = DxErrorCodeData.UNKNOWN_ERROR.getCode();
}
this.message = message;
}
public static ApiResult error(String code, String message, Exception exception) {
ApiResult result = new ApiResult();
result.setCode(StringUtils.isNotBlank(code) ? code : DxErrorCodeData.UNKNOWN_ERROR.getCode());
result.setMessage(StringUtils.isNotBlank(message) ? message : NestedExceptionUtils.buildMessage(DxErrorCodeData.UNKNOWN_ERROR.getValue(), exception));
result.setError(exception);
return result;
}
public static ApiResult error(String code, String message, DxBusinessException exception) {
ApiResult result = new ApiResult();
result.setCode(StringUtils.isNotBlank(code) ? code : DxErrorCodeData.UNKNOWN_ERROR.getCode());
result.setMessage(StringUtils.isNotBlank(message) ? message : DxErrorCodeData.UNKNOWN_ERROR.getValue());
result.setError(exception);
return result;
}
public static ApiResult error(DxBusinessException dxBusinessException) {
return error(dxBusinessException.getCode(), dxBusinessException.getMessage(), dxBusinessException);
}
public static ApiResult error(DxEnumData error, Exception exception) {
return error(error.getCode(), error.getValue(), exception);
}
public static <T> ApiResult ok(T obj, String message) {
ApiResult result = new ApiResult(obj);
result.setMessage(message);
return result;
}
public static <T> ApiResult ok(T obj, DxEnumData dxEnumData) {
ApiResult result = new ApiResult(obj);
result.setMessage(dxEnumData.getValue());
return result;
}
public static <T> ApiResult ok(T obj) {
return ok(obj, (DxEnumData) DxErrorCodeData.SUCCESS);
}
public String getCode() {
return this.code;
}
public String getMessage() {
return this.message;
}
public T getItems() {
return this.items;
}
public Exception getError() {
return this.error;
}
public void setCode(String code) {
this.code = code;
}
public void setMessage(String message) {
this.message = message;
}
public void setItems(T items) {
this.items = items;
}
public void setError(Exception error) {
this.error = error;
}
public String toString() {
return "ApiResult(code=" + this.getCode() + ", message=" + this.getMessage() + ", items=" + this.getItems() + ", error=" + this.getError() + ")";
}
}
package com.yonde.basedata.entity.users;
import com.yonde.basedata.vo.IdVO;
public class DxPrincipalVO extends IdVO {
private String name;
private String num;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
package com.yonde.basedata.entity.users;
import com.yonde.basedata.entity.users.DxPrincipalVO;
import wt.fc.PersistenceHelper;
import wt.org.WTPrincipal;
import wt.org.WTUser;
import wt.util.WTException;
public class DxUserVO extends DxPrincipalVO {
private String nickName;
private String gender;
private String mail;
private String telephone;
private String secretCode;
private String imgUrlId;
private Boolean isInnerUser;
private Boolean isServerUser;
private Boolean enableFlag;
private String userAccount;
private Boolean existAccount;
private Long userId;
public DxUserVO() {
}
public DxUserVO(WTPrincipal principal) throws WTException {
if (principal != null) {
WTUser user = (WTUser) principal;
this.userId = PersistenceHelper.getObjectIdentifier(user).getId();
this.setName(user.getFullName());
this.setNum(user.getName());
this.setId(userId);
this.telephone = user.getTelephoneNumber();
this.mail = user.getEMail();
//TODO 属性匹配
}
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getSecretCode() {
return secretCode;
}
public void setSecretCode(String secretCode) {
this.secretCode = secretCode;
}
public String getImgUrlId() {
return imgUrlId;
}
public void setImgUrlId(String imgUrlId) {
this.imgUrlId = imgUrlId;
}
public Boolean getInnerUser() {
return isInnerUser;
}
public void setInnerUser(Boolean innerUser) {
isInnerUser = innerUser;
}
public Boolean getServerUser() {
return isServerUser;
}
public void setServerUser(Boolean serverUser) {
isServerUser = serverUser;
}
public Boolean getEnableFlag() {
return enableFlag;
}
public void setEnableFlag(Boolean enableFlag) {
this.enableFlag = enableFlag;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
public Boolean getExistAccount() {
return existAccount;
}
public void setExistAccount(Boolean existAccount) {
this.existAccount = existAccount;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
}
package com.yonde.basedata.exception;
import com.yonde.basedata.data.DxEnumData;
public class DxBusinessException extends RuntimeException{
private String code;
private String message;
/** @deprecated */
@Deprecated
public DxBusinessException() {
}
public DxBusinessException(DxEnumData exceptionEnum) {
super(exceptionEnum.getValue());
this.code = exceptionEnum.getCode();
this.message = exceptionEnum.getValue();
}
public DxBusinessException(String code, String message) {
super(message);
this.code = code;
this.message = message;
}
public DxBusinessException(String code, String message, Throwable cause) {
super(cause);
this.code = code;
this.message = message;
}
public DxBusinessException(DxEnumData exceptionEnum, Throwable cause) {
super(cause);
this.code = exceptionEnum.getCode();
this.message = exceptionEnum.getValue();
}
public String getCode() {
return this.code;
}
public String getMessage() {
return this.message;
}
}
package com.yonde.basedata.exception;
import com.yonde.basedata.data.DxEnumData;
public enum DxErrorCodeData implements DxEnumData {
SUCCESS(0, "成功!"),
UNKNOWN_ERROR(500, "服务器错误!"),
FAILURE(2, "基本业务异常"),
COMPILATION_FAILED(3, "编译失败"),
NO_SUCH_FILED(4, "Error: NoSuchField in %s for %s."),
NO_SUCH_METHOD(5, "Error: NoSuchMethod in %s for %s."),
CANNOT_EXECUTE_PRIVATE_METHOD(6, "Error: Cannot execute a private method. in %s. "),
INVOCATION_TARGET_EXCEPTION(7, "Error: InvocationTargetException on getMethodValue."),
PARENT_TYPE_ERROR(8, "获取泛型实际类型出错,类%s不是%s的父接口"),
TO_JSON_ERROR(9, "Json转换失败"),
OPERATE_FREQUENTLY_ERROR(10, "操作过频繁,请稍后重试!"),
NO_SUCH_CLASS(11, "没有找到对应的类,类全路径%s"),
CONSTRUCTION_FAIL(12, "初始化失败,类全路径%s"),
DATA_HAD_CHANGED(13, "数据已经被更改,请刷新后重试!"),
METHOD_ARG_NOT_VALID(14, "方法参数异常: %s"),
DATA_BASE_VIOLATION(15, "存在重复数据,请检查"),
MAX_UPLOAD_FILE(16, "文件大小超过上传限制"),
FEIGN_EXCEPTION(17, "远程feign发生异常 %s"),
ILLEGALARGS(18, "目标类[%s]不可分配给可编辑类[%s]"),
PROP_MAPPING_ERROR(19, "目标类[%s]属性映射错误[%s]"),
CURRENT_NOT_SUPPORT_CUSTOM_TYPE(20, "当前系统不支持自定义类型(json转对象)"),
CAN_NOT_FOUND_DX_TYPE(21, "没有找见对应的dxType类型[%s]");
public static final String PREFIX = "BASEDATA_";
final String code;
final String value;
@Override
public String getCode() {
return this.code;
}
@Override
public String getValue() {
return this.value;
}
private DxErrorCodeData(int code, String value) {
this.code = "BASEDATA_" + String.format("%04d", code);
this.value = value;
}
}
package com.yonde.basedata.search;
import com.yonde.basedata.data.Logical;
import com.yonde.common.ObjectsUtil;
import java.util.*;
public class BaseSearchCondition {
protected SearchItems searchItems;
protected Integer pageFrom;
protected Integer pageSize;
protected List<SortItem> sortItem;
public BaseSearchCondition(SearchItems searchItems, Integer pageFrom, Integer pageSize, List<SortItem> sortItem) {
this.convert(searchItems);
this.searchItems = searchItems;
this.pageFrom = pageFrom;
this.pageSize = pageSize;
this.sortItem = new ArrayList(sortItem);
}
private void convert(SearchItems sis) {
if (!ObjectsUtil.isNull(sis)) {
List<SearchItem> items = sis.getItems();
List<SearchItems> children = sis.getChildren();
sis.setChildren(new ArrayList(children));
sis.setItems(new ArrayList(items));
Iterator var4 = children.iterator();
while(var4.hasNext()) {
SearchItems child = (SearchItems)var4.next();
this.convert(child);
}
}
}
public void addSearchItemWithAnd(SearchItem... si) {
List<SearchItem> list = (List) Arrays.asList(si);
if (ObjectsUtil.isNull(this.searchItems)) {
this.searchItems = new SearchItems();
}
if (this.searchItems.getOperator() == SearchItems.BooleanOperator.AND) {
Object originSearchItems;
if (ObjectsUtil.nonNull(this.searchItems.getItems())) {
originSearchItems = this.searchItems.getItems();
} else {
originSearchItems = new ArrayList();
this.searchItems.setItems((List)originSearchItems);
}
((List)originSearchItems).addAll(list);
} else {
SearchItems ssi = new SearchItems();
ssi.setOperator(SearchItems.BooleanOperator.AND);
List<SearchItems> children = new ArrayList();
children.add(this.searchItems);
ssi.setChildren(children);
ssi.setItems(list);
this.searchItems = ssi;
}
}
public void addSearchItemWithOr(SearchItem... si) {
List<SearchItem> list = Arrays.asList(si);
if (ObjectsUtil.isNull(this.searchItems)) {
this.searchItems = new SearchItems();
}
if (this.searchItems.getOperator() == SearchItems.BooleanOperator.OR) {
Object originSearchItems;
if (ObjectsUtil.nonNull(this.searchItems.getItems())) {
originSearchItems = this.searchItems.getItems();
} else {
originSearchItems = new ArrayList();
this.searchItems.setItems((List)originSearchItems);
}
((List)originSearchItems).addAll(list);
} else {
SearchItems ssi = new SearchItems();
ssi.setOperator(SearchItems.BooleanOperator.OR);
List<SearchItems> children = new ArrayList();
children.add(this.searchItems);
ssi.setChildren(children);
ssi.setItems(list);
this.searchItems = ssi;
}
}
public void addSearchItemsWithLogical(SearchItems si, Logical logical) {
if (ObjectsUtil.isNull(this.searchItems)) {
this.searchItems = si;
} else if (this.searchItems.getOperator().name().equalsIgnoreCase(logical.name())) {
Object list;
if (ObjectsUtil.isNull(this.searchItems.getChildren())) {
list = new ArrayList();
this.searchItems.setChildren((List)list);
} else {
list = this.searchItems.getChildren();
}
if (this.searchItems.getOperator().name().equals(si.getOperator().name())) {
this.searchItems.getItems().addAll(si.getItems());
this.searchItems.getChildren().addAll(si.getChildren());
} else {
((List)list).add(si);
}
} else {
SearchItems newSearchItems = new SearchItems();
SearchItems.BooleanOperator operator = logical == Logical.AND ? SearchItems.BooleanOperator.AND : SearchItems.BooleanOperator.OR;
newSearchItems.setOperator(operator);
List<SearchItems> list = new ArrayList(2);
newSearchItems.setChildren(list);
list.add(si);
list.add(this.searchItems);
this.searchItems = newSearchItems;
}
}
public void addBranchIdSearchItem(List<String> branchIds) {
if (!ObjectsUtil.isNull(branchIds) && !branchIds.isEmpty()) {
SearchItem si = new SearchItem();
si.fieldName = "branchId";
si.operator = SearchItem.Operator.IN;
si.value = ObjectsUtil.join(",", branchIds);
this.searchItems.addItem(si);
this.addSearchItemWithOr(si);
}
}
public void addSearchItemsWithAnd(SearchItems addSearchItems) {
if (ObjectsUtil.isNull(this.searchItems)) {
this.searchItems = new SearchItems();
}
if (this.searchItems.getOperator() == SearchItems.BooleanOperator.AND) {
this.searchItems.addChild(addSearchItems);
} else {
SearchItems ssi = new SearchItems();
ssi.setOperator(SearchItems.BooleanOperator.AND);
List<SearchItems> children = new ArrayList();
children.add(this.searchItems);
children.add(addSearchItems);
ssi.setChildren(children);
this.searchItems = ssi;
}
}
public SearchItems getSearchItems() {
return this.searchItems;
}
public Integer getPageFrom() {
return this.pageFrom;
}
public Integer getPageSize() {
return this.pageSize;
}
public List<SortItem> getSortItem() {
return this.sortItem;
}
public void setSearchItems(SearchItems searchItems) {
this.searchItems = searchItems;
}
public void setPageFrom(Integer pageFrom) {
this.pageFrom = pageFrom;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public void setSortItem(List<SortItem> sortItem) {
this.sortItem = sortItem;
}
}
package com.yonde.basedata.search;
import com.yonde.basedata.data.DxEnumData;
public class SearchItem {
public String fieldName;
public Object value;
public Object value1;
public SearchItem.Operator operator;
public String searchItemType;
public SearchItem() {
}
public SearchItem(String fieldName, SearchItem.Operator operator, Object value, Object value1) {
this.fieldName = fieldName;
this.value = value;
this.operator = operator;
this.value1 = value1;
}
public static enum Operator implements DxEnumData {
EQ(1, "等于"),
NEQ(2, "不等于"),
LIKE(3, "模糊查询"),
GT(4, "大于"),
LT(5, "小于"),
GTE(6, "大于等于"),
LTE(7, "小于等于"),
BTWN(8, "范围查询"),
IN(9, "多值查询"),
ISNULL(10, "空值查询"),
NOTNULL(11, "非空查询"),
FULLLIKE(12, "全模糊查询"),
NOTIN(13, "非集合查询");
final String code;
final String value;
private Operator(int code, String value) {
this.code = String.format("%04d", code);
this.value = value;
}
public String getCode() {
return this.code;
}
public String getValue() {
return this.value;
}
private Operator(String code, String value) {
this.code = code;
this.value = value;
}
}
}
package com.yonde.basedata.search;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class SearchItems {
private List<SearchItem> items = new ArrayList();
private List<SearchItems> children = new ArrayList();
private SearchItems.BooleanOperator operator;
public SearchItems(List<SearchItem> items, List<SearchItems> children, SearchItems.BooleanOperator operator) {
this.items = new ArrayList(items);
this.children = new ArrayList(children);
this.operator = operator;
}
public SearchItems() {
this.operator = SearchItems.BooleanOperator.AND;
}
public SearchItems(SearchItems.BooleanOperator operator) {
this.operator = operator;
}
public static SearchItems of(SearchItems.BooleanOperator operator, SearchItem... item) {
SearchItems items = new SearchItems(operator);
SearchItem[] var3 = item;
int var4 = item.length;
for(int var5 = 0; var5 < var4; ++var5) {
SearchItem si = var3[var5];
items.addItem(si);
}
return items;
}
public static SearchItems of(SearchItems.BooleanOperator operator, SearchItems... item) {
SearchItems items = new SearchItems(operator);
SearchItems[] var3 = item;
int var4 = item.length;
for(int var5 = 0; var5 < var4; ++var5) {
SearchItems si = var3[var5];
items.addChild(si);
}
return items;
}
public void addItem(SearchItem item) {
this.items.add(item);
}
public void removeItem(SearchItem item) {
this.items.remove(item);
}
public void addChild(SearchItems item) {
this.children.add(item);
}
private static SearchItems.BooleanOperator $default$operator() {
return SearchItems.BooleanOperator.AND;
}
public static SearchItems.SearchItemsBuilder builder() {
return new SearchItems.SearchItemsBuilder();
}
public List<SearchItem> getItems() {
return this.items;
}
public List<SearchItems> getChildren() {
return this.children;
}
public SearchItems.BooleanOperator getOperator() {
return this.operator;
}
public void setItems(List<SearchItem> items) {
this.items = items;
}
public void setChildren(List<SearchItems> children) {
this.children = children;
}
public void setOperator(SearchItems.BooleanOperator operator) {
this.operator = operator;
}
public static class SearchItemsBuilder {
private ArrayList<SearchItem> items;
private ArrayList<SearchItems> children;
private boolean operator$set;
private SearchItems.BooleanOperator operator$value;
SearchItemsBuilder() {
}
public SearchItems.SearchItemsBuilder item(SearchItem item) {
if (this.items == null) {
this.items = new ArrayList();
}
this.items.add(item);
return this;
}
public SearchItems.SearchItemsBuilder items(Collection<? extends SearchItem> items) {
if (items == null) {
throw new NullPointerException("items cannot be null");
} else {
if (this.items == null) {
this.items = new ArrayList();
}
this.items.addAll(items);
return this;
}
}
public SearchItems.SearchItemsBuilder clearItems() {
if (this.items != null) {
this.items.clear();
}
return this;
}
public SearchItems.SearchItemsBuilder child(SearchItems child) {
if (this.children == null) {
this.children = new ArrayList();
}
this.children.add(child);
return this;
}
public SearchItems.SearchItemsBuilder children(Collection<? extends SearchItems> children) {
if (children == null) {
throw new NullPointerException("children cannot be null");
} else {
if (this.children == null) {
this.children = new ArrayList();
}
this.children.addAll(children);
return this;
}
}
public SearchItems.SearchItemsBuilder clearChildren() {
if (this.children != null) {
this.children.clear();
}
return this;
}
public SearchItems.SearchItemsBuilder operator(SearchItems.BooleanOperator operator) {
this.operator$value = operator;
this.operator$set = true;
return this;
}
public SearchItems build() {
List items;
switch(this.items == null ? 0 : this.items.size()) {
case 0:
items = Collections.emptyList();
break;
case 1:
items = Collections.singletonList(this.items.get(0));
break;
default:
items = Collections.unmodifiableList(new ArrayList(this.items));
}
List children;
switch(this.children == null ? 0 : this.children.size()) {
case 0:
children = Collections.emptyList();
break;
case 1:
children = Collections.singletonList(this.children.get(0));
break;
default:
children = Collections.unmodifiableList(new ArrayList(this.children));
}
SearchItems.BooleanOperator operator$value = this.operator$value;
if (!this.operator$set) {
operator$value = SearchItems.$default$operator();
}
return new SearchItems(items, children, operator$value);
}
public String toString() {
return "SearchItems.SearchItemsBuilder(items=" + this.items + ", children=" + this.children + ", operator$value=" + this.operator$value + ")";
}
}
public static enum BooleanOperator {
AND,
OR;
private BooleanOperator() {
}
}
}
This diff is collapsed.
package com.yonde.basedata.search;
public class SortItem {
private String fieldName;
private String sortOrder;
public static SortItem.SortItemBuilder builder() {
return new SortItem.SortItemBuilder();
}
public String getFieldName() {
return this.fieldName;
}
public String getSortOrder() {
return this.sortOrder;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
public SortItem(String fieldName, String sortOrder) {
this.fieldName = fieldName;
this.sortOrder = sortOrder;
}
public SortItem() {
}
public static class SortItemBuilder {
private String fieldName;
private String sortOrder;
SortItemBuilder() {
}
public SortItem.SortItemBuilder fieldName(String fieldName) {
this.fieldName = fieldName;
return this;
}
public SortItem.SortItemBuilder sortOrder(String sortOrder) {
this.sortOrder = sortOrder;
return this;
}
public SortItem build() {
return new SortItem(this.fieldName, this.sortOrder);
}
public String toString() {
return "SortItem.SortItemBuilder(fieldName=" + this.fieldName + ", sortOrder=" + this.sortOrder + ")";
}
}
}
package com.yonde.basedata.service;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.vo.IdVO;
public interface BaseSearchService <V extends IdVO>{
DxPageImpl<V> search(SearchQueryCondition searchQueryCondition);
ApiResult saveRecursion(V entity);
}
package com.yonde.basedata.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.yonde.basedata.entity.users.DxUserVO;
public interface BaseDataVO {
Long getId();
void setId(Long var1);
Long getCreatorId();
void setCreatorId(Long var1);
@JsonSerialize(
as = DxUserVO.class
)
DxUserVO getCreator();
void setCreator(DxUserVO var1);
Long getModifierId();
void setModifierId(Long var1);
@JsonSerialize(
as = DxUserVO.class
)
DxUserVO getModifier();
void setModifier(DxUserVO var1);
String getSubTypeName();
void setSubTypeName(String var1);
String getSubTypeDisplayName();
void setSubTypeDisplayName(String var1);
/* OperatorType getOperator();
void setOperator(OperatorType var1);*/
String getDxClassname();
void setDxClassname(String var1);
}
package com.yonde.basedata.vo;
import com.yonde.doc.vo.DxDocumentVO;
import java.util.List;
public class DxDocumentFolderVO extends IdVO{
private String fullPath;
private String name;
private Boolean isLeaf;
private List<DxDocumentVO> dxDocuments;
}
package com.yonde.basedata.vo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.common.DateTimeUtil;
import wt.doc.WTDocument;
import wt.doc.WTDocumentMaster;
import wt.enterprise.RevisionControlled;
import wt.fc.PersistenceHelper;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.util.WTException;
import java.util.Locale;
public class DxMasterVO {
private String number;
private String name;
private String objectType;
private String createTime;
private String modifyTime;
private Long creatorId;
private Long modifierId;
private DxUserVO creator;
private DxUserVO modifier;
private Long id;
public DxMasterVO() {
}
public DxMasterVO(RevisionControlled controlled) throws WTException {
if(null != controlled) {
if (controlled instanceof WTDocument) {
WTDocument doc = (WTDocument) controlled;
WTDocumentMaster wtDocumentMaster = (WTDocumentMaster) doc.getMaster();
this.id = PersistenceHelper.getObjectIdentifier(wtDocumentMaster).getId();
this.number = wtDocumentMaster.getNumber();
this.name = wtDocumentMaster.getName();
this.createTime = DateTimeUtil.timeStampToString(wtDocumentMaster.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(wtDocumentMaster.getModifyTimestamp());
} else if(controlled instanceof WTPart) {
WTPart part = (WTPart) controlled;
WTPartMaster wtPartMaster = (WTPartMaster) part.getMaster();
this.id = PersistenceHelper.getObjectIdentifier(wtPartMaster).getId();
this.number = wtPartMaster.getNumber();
this.name = wtPartMaster.getName();
this.createTime = DateTimeUtil.timeStampToString(wtPartMaster.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(wtPartMaster.getModifyTimestamp());
}
this.objectType = controlled.getDisplayType().getLocalizedMessage(Locale.SIMPLIFIED_CHINESE);
this.creator = new DxUserVO(controlled.getCreator().getPrincipal());
this.modifier = new DxUserVO(controlled.getModifier().getPrincipal());
this.creatorId = creator.getUserId();
this.modifierId = modifier.getUserId();
}
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getObjectType() {
return objectType;
}
public void setObjectType(String objectType) {
this.objectType = objectType;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public Long getCreatorId() {
return creatorId;
}
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
}
public Long getModifierId() {
return modifierId;
}
public void setModifierId(Long modifierId) {
this.modifierId = modifierId;
}
public DxUserVO getCreator() {
return creator;
}
public void setCreator(DxUserVO creator) {
this.creator = creator;
}
public DxUserVO getModifier() {
return modifier;
}
public void setModifier(DxUserVO modifier) {
this.modifier = modifier;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
package com.yonde.basedata.vo;
import wt.fc.PersistenceHelper;
import wt.org.WTOrganization;
import wt.util.WTException;
public class DxOrganizationVO extends IdVO{
private String name;
private String num;
private String description;
public DxOrganizationVO() {
}
public DxOrganizationVO(WTOrganization organization) throws WTException {
this.name = organization.getName();
this.description = organization.getDescription();
this.id = PersistenceHelper.getObjectIdentifier(organization).getId();
}
}
package com.yonde.basedata.vo;
import com.yonde.common.DateTimeUtil;
import wt.enterprise.RevisionControlled;
import wt.fc.PersistenceHelper;
import wt.util.WTException;
import wt.vc.wip.WorkInProgressHelper;
public class DxVersionVO {
private String versionKey;
private String versionSeries;
private Long predecessorId;
private DxVersionVO predecessor;
private Long masterId;
private DxMasterVO master;
private Boolean checkOuted;
private Long dxViewId;
private Long versionId;
private String displayVersion;
private String iterationId;
private String iterationCreateTime;
private Long iterationCreateId;
public DxVersionVO() {
}
public DxVersionVO(RevisionControlled controlled) throws WTException {
if(null != controlled) {
this.versionKey = controlled.getVersionIdentifier().getValue();
this.masterId = PersistenceHelper.getObjectIdentifier(controlled.getMaster()).getId();
this.master = new DxMasterVO(controlled);
this.checkOuted = WorkInProgressHelper.isCheckedOut(controlled);
this.versionId = PersistenceHelper.getObjectIdentifier(controlled).getId();
this.displayVersion = this.versionKey + "." + controlled.getIterationIdentifier().getValue();
this.iterationId = controlled.getIterationIdentifier().getValue();
this.iterationCreateTime = DateTimeUtil.timeStampToString(controlled.getCreateTimestamp());
this.iterationCreateId = PersistenceHelper.getObjectIdentifier(controlled.getCreator().getObject()).getId();
}
}
public String getVersionKey() {
return versionKey;
}
public void setVersionKey(String versionKey) {
this.versionKey = versionKey;
}
public String getVersionSeries() {
return versionSeries;
}
public void setVersionSeries(String versionSeries) {
this.versionSeries = versionSeries;
}
public Long getPredecessorId() {
return predecessorId;
}
public void setPredecessorId(Long predecessorId) {
this.predecessorId = predecessorId;
}
public DxVersionVO getPredecessor() {
return predecessor;
}
public void setPredecessor(DxVersionVO predecessor) {
this.predecessor = predecessor;
}
public Long getMasterId() {
return masterId;
}
public void setMasterId(Long masterId) {
this.masterId = masterId;
}
public DxMasterVO getMaster() {
return master;
}
public void setMaster(DxMasterVO master) {
this.master = master;
}
public Boolean getCheckOuted() {
return checkOuted;
}
public void setCheckOuted(Boolean checkOuted) {
this.checkOuted = checkOuted;
}
public Long getDxViewId() {
return dxViewId;
}
public void setDxViewId(Long dxViewId) {
this.dxViewId = dxViewId;
}
public Long getVersionId() {
return versionId;
}
public void setVersionId(Long versionId) {
this.versionId = versionId;
}
public String getDisplayVersion() {
return displayVersion;
}
public void setDisplayVersion(String displayVersion) {
this.displayVersion = displayVersion;
}
public String getIterationId() {
return iterationId;
}
public void setIterationId(String iterationId) {
this.iterationId = iterationId;
}
public String getIterationCreateTime() {
return iterationCreateTime;
}
public void setIterationCreateTime(String iterationCreateTime) {
this.iterationCreateTime = iterationCreateTime;
}
public Long getIterationCreateId() {
return iterationCreateId;
}
public void setIterationCreateId(Long iterationCreateId) {
this.iterationCreateId = iterationCreateId;
}
}
package com.yonde.basedata.vo;
import java.util.Map;
public class IdOnlyVO {
protected Long id;
protected String subTypeName;
protected String subTypeDisplayName;
protected Map<String, Object> dynamicAttrs;
protected Long objOrgId;
public IdOnlyVO() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSubTypeName() {
return subTypeName;
}
public void setSubTypeName(String subTypeName) {
this.subTypeName = subTypeName;
}
public String getSubTypeDisplayName() {
return subTypeDisplayName;
}
public void setSubTypeDisplayName(String subTypeDisplayName) {
this.subTypeDisplayName = subTypeDisplayName;
}
public Map<String, Object> getDynamicAttrs() {
return dynamicAttrs;
}
public void setDynamicAttrs(Map<String, Object> dynamicAttrs) {
this.dynamicAttrs = dynamicAttrs;
}
public Long getObjOrgId() {
return objOrgId;
}
public void setObjOrgId(Long objOrgId) {
this.objOrgId = objOrgId;
}
}
package com.yonde.basedata.vo;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.basedata.entity.users.DxUserVO;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "dxClassname",visible = true)
public class IdVO extends IdOnlyVO{
protected String dxClassname;
protected DxUserVO creator;
protected DxUserVO modifier;
protected Long creatorId;
protected Long modifierId;
protected String modifyTime;
protected String createTime;
public String getDxClassname() {
return dxClassname;
}
public void setDxClassname(String dxClassname) {
this.dxClassname = dxClassname;
}
public DxUserVO getCreator() {
return creator;
}
public void setCreator(DxUserVO creator) {
this.creator = creator;
}
public DxUserVO getModifier() {
return modifier;
}
public void setModifier(DxUserVO modifier) {
this.modifier = modifier;
}
public Long getCreatorId() {
return creatorId;
}
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
}
public Long getModifierId() {
return modifierId;
}
public void setModifierId(Long modifierId) {
this.modifierId = modifierId;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}
package com.yonde.basedata.vo;
public class RevisionControlledVO extends IdVO{
private DxVersionVO version;
private Long versionId;
private String versionKey;
private String displayVersion;
private String iterationId;
private String iterationCreateTime;
private Long iterationCreateId;
private DxMasterVO masterVO;
private Long masterId;
public DxVersionVO getVersion() {
return version;
}
public void setVersion(DxVersionVO version) {
this.version = version;
this.versionId = version.getVersionId();
this.versionKey = version.getVersionKey();
this.displayVersion = version.getDisplayVersion();
this.iterationId = version.getIterationId();
this.iterationCreateId = version.getIterationCreateId();
this.iterationCreateTime = version.getIterationCreateTime();
}
public DxMasterVO getMasterVO() {
return masterVO;
}
public void setMasterVO(DxMasterVO masterVO) {
this.masterVO = masterVO;
this.masterId = masterVO.getId();
//this.name = masterVO.getName();
//this.number = masterVO.getNumber();
}
public Long getMasterId() {
return masterId;
}
public void setMasterId(Long masterId) {
this.masterId = masterId;
}
public Long getVersionId() {
return versionId;
}
public void setVersionId(Long versionId) {
this.versionId = versionId;
}
public String getVersionKey() {
return versionKey;
}
public void setVersionKey(String versionKey) {
this.versionKey = versionKey;
}
public String getDisplayVersion() {
return displayVersion;
}
public void setDisplayVersion(String displayVersion) {
this.displayVersion = displayVersion;
}
public String getIterationId() {
return iterationId;
}
public void setIterationId(String iterationId) {
this.iterationId = iterationId;
}
public String getIterationCreateTime() {
return iterationCreateTime;
}
public void setIterationCreateTime(String iterationCreateTime) {
this.iterationCreateTime = iterationCreateTime;
}
public Long getIterationCreateId() {
return iterationCreateId;
}
public void setIterationCreateId(Long iterationCreateId) {
this.iterationCreateId = iterationCreateId;
}
}
This diff is collapsed.
This diff is collapsed.
package com.yonde.common;
import com.ptc.core.foundation.type.server.impl.TypeHelper;
import com.ptc.core.meta.common.TypeIdentifier;
import com.ptc.core.meta.common.TypeIdentifierHelper;
import org.apache.log4j.Logger;
import wt.doc.WTDocument;
import wt.doc.WTDocumentDependencyLink;
import wt.doc.WTDocumentHelper;
import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.PersistenceServerHelper;
import wt.fc.QueryResult;
import wt.util.WTException;
import java.util.ArrayList;
import java.util.List;
import static org.apache.commons.lang.StringUtils.isNotBlank;
public class LinkObjUtil {
private static Logger logger = Logger.getLogger(LinkObjUtil.class);
/**
* 获取指定类型的参考文档 号对版本
*
* @param doc
* @return
*/
public static List<WTDocument> getDependsOnDocument(WTDocument doc, String type) {
List<WTDocument> doclist = new ArrayList<WTDocument>();
try {
if (doc != null) {
QueryResult qr = WTDocumentHelper.service.getDependsOnWTDocuments(doc);
while (qr.hasMoreElements()) {
WTDocument cdoc = (WTDocument) qr.nextElement();
// 判断类型
if (type != null && !type.isEmpty()) {
TypeIdentifier td = TypeIdentifierHelper.getType(cdoc);
if (TypeHelper.isA(td, TypeHelper.getTypeIdentifier(type))) {
doclist.add(cdoc);
}
} else {
doclist.add(cdoc);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return doclist;
}
/**
* 获取参考文档 号对版本
*
* @param doc
* @return
*/
public static List<WTDocument> getDependsOnDocument(WTDocument doc) {
List<WTDocument> doclist = new ArrayList();
try {
if (doc != null) {
QueryResult qr = WTDocumentHelper.service.getDependsOnWTDocuments(doc);
while (qr.hasMoreElements()) {
WTDocument cdoc = (WTDocument) qr.nextElement();
doclist.add(cdoc);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return doclist;
}
/**
* 根据类型获取所参考文档
*
* @param doc
* @return
*/
public static WTDocument getHasDependentDocument(WTDocument doc, String type) {
WTDocument pdoc = null;
try {
if (doc != null) {
QueryResult qr = WTDocumentHelper.service.getHasDependentWTDocuments(doc, false);
while (qr.hasMoreElements()) {
WTDocumentDependencyLink link = (WTDocumentDependencyLink) qr.nextElement();
pdoc = (WTDocument) link.getRoleAObject();
// 判断类型
if (type != null && !type.isEmpty()) {
TypeIdentifier td = TypeIdentifierHelper.getType(pdoc);
if (TypeHelper.isA(td, TypeHelper.getTypeIdentifier(type))) {
return pdoc;
}
} else {
return pdoc;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取所参考文档
*
* @param doc
* @return
*/
public static WTDocument getHasDependentDocument(WTDocument doc) {
//TODO 有问题,为什么参考文档只会有一个?
try {
if (doc != null) {
QueryResult qr = WTDocumentHelper.service.getHasDependentWTDocuments(doc, false);
while (qr.hasMoreElements()) {
WTDocumentDependencyLink link = (WTDocumentDependencyLink) qr.nextElement();
WTDocument pdoc = (WTDocument) link.getRoleAObject();
return pdoc;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取所参考文档
*
* @param doc
* @return
*/
public static List<WTDocument> getHasDependentDocuments(WTDocument doc) {
//TODO 有问题,为什么参考文档只会有一个?
List<WTDocument> rs = new ArrayList<WTDocument>();
try {
if (doc != null) {
QueryResult qr = WTDocumentHelper.service.getHasDependentWTDocuments(doc, false);
while (qr.hasMoreElements()) {
WTDocumentDependencyLink link = (WTDocumentDependencyLink) qr.nextElement();
WTDocument pdoc = (WTDocument) link.getRoleAObject();
rs.add(pdoc);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
/**
* 查找文档之间的参考关系
*
* @param doc1
* @param doc2
* @return
* @throws WTException
*/
public static WTDocumentDependencyLink getDocDependencyLink(WTDocument doc1, WTDocument doc2) throws WTException {
QueryResult queryresult = PersistenceHelper.manager.find(WTDocumentDependencyLink.class, doc1, WTDocumentDependencyLink.DESCRIBES_ROLE, doc2);
if (queryresult == null || queryresult.size() == 0)
return null;
else
return (WTDocumentDependencyLink) queryresult.nextElement();
}
/**
* 创建参考关系 number 参考 wtdocument
*
* @param number
* @param wtdocument
* @return
* @throws WTException
*/
public static boolean createDocAssociateDoc(String number, WTDocument wtdocument) throws WTException {
WTDocument doc1 = DocUtil.getDoc(number);
WTDocument doc2 = DocUtil.getDoc(wtdocument.getNumber());
WTDocumentDependencyLink wtdocdependencylinkOld = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylinkOld == null) {
logger.debug("no link between the wtdocument and wtdocument,will create");
WTDocumentDependencyLink wtdocdependencylink1 = WTDocumentDependencyLink.newWTDocumentDependencyLink(doc1, doc2);
PersistenceServerHelper.manager.insert(wtdocdependencylink1);
wtdocdependencylink1 = (WTDocumentDependencyLink) PersistenceHelper.manager.refresh(wtdocdependencylink1);
WTDocumentDependencyLink wtdocdependencylink = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylink == null) {
logger.debug("creat wtpart associate doc fail");
return false;
} else
return true;
}
logger.debug("the link has alseardy exist,do not need to create it again");
return false;
}
/**
* 移除参考关系
*
* @param number
* @param wtdocument
* @return
* @throws WTException
*/
public static boolean removeDocAssociateDoc(String number, WTDocument wtdocument) throws WTException {
WTDocument doc1 = DocUtil.getDoc(number);
WTDocument doc2 = DocUtil.getDoc(wtdocument.getNumber());
WTDocumentDependencyLink wtdocdependencylinkOld = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylinkOld != null) {
PersistenceServerHelper.manager.remove(wtdocdependencylinkOld);
logger.debug("Deleting the link...");
return true;
}
logger.debug("the link isn't exist");
return false;
}
/**
* 移除参考关系
*
* @param doc1
* @param doc2
* @return
* @throws WTException
*/
public static boolean removeDocAssociateDoc(WTDocument doc1, WTDocument doc2) throws WTException {
WTDocumentDependencyLink wtdocdependencylinkOld = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylinkOld != null) {
PersistenceServerHelper.manager.remove(wtdocdependencylinkOld);
logger.debug("Deleting the link between " + doc1 + " AND " + doc2 + "...");
return true;
}
logger.debug("the link isn't exist");
return false;
}
/**
* 移除所有参考关系
* @param doc
* @param types 0:全部移除;1:移除被参考;2:移除关联
* @return
* @throws WTException
*/
public static boolean removeDocLinkByDoc(WTDocument doc,String types) throws WTException{
//checkArgument(doc!=null, "文档对象不可为null");
//checkArgument(isNotBlank(types), "文档移除类型不可谓空");
if (types.equals("1")||types.equals("0")) {
//TODO remove 被关联文档
QueryResult qrA = WTDocumentHelper.service.getHasDependentWTDocuments(doc, false);
while (qrA.hasMoreElements()) {
WTDocumentDependencyLink linkA = (WTDocumentDependencyLink) qrA.nextElement();
PersistenceServerHelper.manager.remove(linkA);
logger.debug("Deleting the 被关联文档link");
}
}
if (types.equals("2")||types.equals("0")) {
//TODO remove 关联文档
QueryResult qrB = WTDocumentHelper.service.getDependsOnWTDocuments(doc, false);
while (qrB.hasMoreElements()) {
WTDocumentDependencyLink linkB = (WTDocumentDependencyLink) qrB.nextElement();
PersistenceServerHelper.manager.remove(linkB);
logger.debug("Deleting the 关联文档link");
}
}
//remove 被关联文档
if(types.equals("DelRoleA")){
QueryResult qrA = WTDocumentHelper.service.getHasDependentWTDocuments(doc, false);
while (qrA.hasMoreElements()) {
WTDocumentDependencyLink linkA = (WTDocumentDependencyLink) qrA.nextElement();
Persistable roleA = linkA.getRoleAObject();
PersistenceServerHelper.manager.remove(linkA);
PersistenceServerHelper.manager.remove(roleA);
logger.debug("Deleting the 被关联文档link");
}
}
return true;
}
/**
* 创建参考关系doc1 参考 doc2
*
* @param doc1
* @param doc2
* @return
* @throws WTException
*/
public static boolean createDocAssociateDoc(WTDocument doc1, WTDocument doc2) throws WTException {
WTDocumentDependencyLink wtdocdependencylinkOld = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylinkOld == null) {
logger.debug("no link between the wtdocument and wtdocument,will create");
WTDocumentDependencyLink wtdocdependencylink1 = WTDocumentDependencyLink.newWTDocumentDependencyLink(doc1, doc2);
PersistenceServerHelper.manager.insert(wtdocdependencylink1);
wtdocdependencylink1 = (WTDocumentDependencyLink) PersistenceHelper.manager.refresh(wtdocdependencylink1);
WTDocumentDependencyLink wtdocdependencylink = LinkObjUtil.getDocDependencyLink(doc1, doc2);
if (wtdocdependencylink == null) {
logger.debug("creat wtpart associate doc fail");
return false;
} else
return true;
}
logger.debug("the link has alseardy exist,do not need to create it again");
return false;
}
}
package com.yonde.common;
public class ObjectsUtil {
public static boolean isNull(Object obj) {
return obj == null;
}
public static boolean nonNull(Object obj) {
return obj != null;
}
public static String join(String delimiter,
Iterable<? extends CharSequence> elements) {
StringBuffer joiner = new StringBuffer();
for (CharSequence cs: elements) {
joiner.append(cs + delimiter);
}
return joiner.substring(0, joiner.lastIndexOf(delimiter));
}
}
package com.yonde.common;
import wt.doc.WTDocument;
import wt.fc.PersistenceHelper;
import wt.fc.ReferenceFactory;
import wt.fc.WTObject;
import wt.fc.WTReference;
import wt.lifecycle.LifeCycleHelper;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.vc.VersionControlException;
import wt.vc.VersionControlHelper;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
import static org.apache.commons.lang.StringUtils.isNotBlank;
public class RfUtil {
public static final ReferenceFactory rf = new ReferenceFactory();
public static WTDocument getDoc(String oid){
//checkArgument(isNotBlank(oid));
try {
return (WTDocument) rf.getReference(oid).getObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取对象OR id,不是VR id
*
* @param doc
* @return
*/
public static long getDocOid(WTDocument doc) {
//checkNotNull(doc);
return PersistenceHelper.getObjectIdentifier(doc).getId();
}
/**
* 获取对象VR id,不是OR id
*
* @param doc
* @return
* @throws VersionControlException
*/
public static long getDocVid(WTDocument doc) throws VersionControlException {
//checkNotNull(doc);
return VersionControlHelper.getBranchIdentifier(doc);
}
/**
* 通过oid获取WTObject
*
* @param oid
* @return
* @throws WTException
* @throws RemoteException
* @throws InvocationTargetException
*/
public static WTObject getWTObjectByOid(String oid) throws WTException, RemoteException, InvocationTargetException {
WTObject p = null;
boolean flag = SessionServerHelper.manager.setAccessEnforced(false);
try {
int pos = oid.indexOf("~");
if (pos >= 0)
oid = oid.substring(pos + 1);
WTReference wtreference = rf.getReference(oid);
if (wtreference != null) {
p = (WTObject) wtreference.getObject();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
SessionServerHelper.manager.setAccessEnforced(flag);
}
return p;
}
}
package com.yonde.common.entity;
public interface DxIterationVOHolder {
String authKeys = null;
}
package com.yonde.context.vo;
public class DxContextTeamMemberVO {
}
package com.yonde.context.vo;
public class DxContextTeamVO {
private String role;
private String name;
private String description;
private String oid;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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