|
@@ -20,7 +20,8 @@ import com.x.base.core.project.logger.Logger;
|
|
|
import com.x.base.core.project.logger.LoggerFactory;
|
|
import com.x.base.core.project.logger.LoggerFactory;
|
|
|
import com.x.teamwork.core.entity.Dynamic;
|
|
import com.x.teamwork.core.entity.Dynamic;
|
|
|
import com.x.teamwork.core.entity.Project;
|
|
import com.x.teamwork.core.entity.Project;
|
|
|
-import com.x.teamwork.core.entity.ProjectExtFieldRele;
|
|
|
|
|
|
|
+import com.x.teamwork.core.entity.Task;
|
|
|
|
|
+import com.x.teamwork.core.entity.CustomExtFieldRele;
|
|
|
|
|
|
|
|
public class ActionSave extends BaseAction {
|
|
public class ActionSave extends BaseAction {
|
|
|
|
|
|
|
@@ -28,9 +29,10 @@ public class ActionSave extends BaseAction {
|
|
|
|
|
|
|
|
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
|
|
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
|
|
|
ActionResult<Wo> result = new ActionResult<>();
|
|
ActionResult<Wo> result = new ActionResult<>();
|
|
|
- ProjectExtFieldRele projectExtFieldRele = null;
|
|
|
|
|
- ProjectExtFieldRele projectExtFieldRele_old = null;
|
|
|
|
|
|
|
+ CustomExtFieldRele customExtFieldRele = null;
|
|
|
|
|
+ CustomExtFieldRele customExtFieldRele_old = null;
|
|
|
Project project = null;
|
|
Project project = null;
|
|
|
|
|
+ Task task = null;
|
|
|
Wi wi = null;
|
|
Wi wi = null;
|
|
|
Wo wo = new Wo();
|
|
Wo wo = new Wo();
|
|
|
String fieldName = null;
|
|
String fieldName = null;
|
|
@@ -38,45 +40,59 @@ public class ActionSave extends BaseAction {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
wi = this.convertToWrapIn( jsonElement, Wi.class );
|
|
wi = this.convertToWrapIn( jsonElement, Wi.class );
|
|
|
- projectExtFieldRele = Wi.copier.copy( wi );
|
|
|
|
|
|
|
+ customExtFieldRele = Wi.copier.copy( wi );
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
check = false;
|
|
|
- Exception exception = new ProjectExtFieldRelePersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
|
|
|
|
|
|
|
+ Exception exception = new CustomExtFieldRelePersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
|
|
|
result.error(exception);
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( Boolean.TRUE.equals( check ) ){
|
|
|
|
|
- if( StringUtils.isEmpty( projectExtFieldRele.getProjectId() )) {
|
|
|
|
|
|
|
+ /*if( Boolean.TRUE.equals( check ) ){
|
|
|
|
|
+ if( StringUtils.isEmpty( customExtFieldRele.getProjectId() )) {
|
|
|
check = false;
|
|
check = false;
|
|
|
Exception exception = new ProjectFlagForQueryEmptyException();
|
|
Exception exception = new ProjectFlagForQueryEmptyException();
|
|
|
result.error( exception );
|
|
result.error( exception );
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
- try {
|
|
|
|
|
- project = projectQueryService.get( projectExtFieldRele.getProjectId() );
|
|
|
|
|
- if ( project == null) {
|
|
|
|
|
|
|
+ if(StringUtils.isNotEmpty( customExtFieldRele.getCorrelationId() )){
|
|
|
|
|
+ try {
|
|
|
|
|
+ if(StringUtils.equals(customExtFieldRele.getType(), "project")){
|
|
|
|
|
+ project = projectQueryService.get( customExtFieldRele.getCorrelationId() );
|
|
|
|
|
+ if ( project == null) {
|
|
|
|
|
+ check = false;
|
|
|
|
|
+ Exception exception = new ProjectNotExistsException( customExtFieldRele.getCorrelationId() );
|
|
|
|
|
+ result.error( exception );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.equals(customExtFieldRele.getType(), "task")){
|
|
|
|
|
+ task = taskQueryService.get( customExtFieldRele.getCorrelationId() );
|
|
|
|
|
+ if ( task == null) {
|
|
|
|
|
+ check = false;
|
|
|
|
|
+ Exception exception = new TaskNotExistsException( customExtFieldRele.getCorrelationId() );
|
|
|
|
|
+ result.error( exception );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
check = false;
|
|
check = false;
|
|
|
- Exception exception = new ProjectNotExistsException( projectExtFieldRele.getProjectId() );
|
|
|
|
|
- result.error( exception );
|
|
|
|
|
|
|
+ Exception exception = new CustomExtFieldRelePersistException(e, "根据指定flag查询应用项目信息对象时发生异常。flag:" + customExtFieldRele.getCorrelationId() );
|
|
|
|
|
+ result.error(exception);
|
|
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- check = false;
|
|
|
|
|
- Exception exception = new ProjectExtFieldRelePersistException(e, "根据指定flag查询应用项目信息对象时发生异常。flag:" + projectExtFieldRele.getProjectId() );
|
|
|
|
|
- result.error(exception);
|
|
|
|
|
- logger.error(e, effectivePerson, request, null);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
- if( StringUtils.isNotEmpty( projectExtFieldRele.getId() )) {
|
|
|
|
|
|
|
+ if( StringUtils.isNotEmpty( customExtFieldRele.getId() )) {
|
|
|
try {
|
|
try {
|
|
|
- projectExtFieldRele_old = projectExtFieldReleQueryService.get( projectExtFieldRele.getId() );
|
|
|
|
|
|
|
+ customExtFieldRele_old = customExtFieldReleQueryService.get( customExtFieldRele.getId() );
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
check = false;
|
|
|
- Exception exception = new ProjectExtFieldReleQueryException(e, "系统在根据ID查询指定的扩展属性关联信息时发生异常。ID:" + projectExtFieldRele.getId() );
|
|
|
|
|
|
|
+ Exception exception = new CustomExtFieldReleQueryException(e, "系统在根据ID查询指定的扩展属性关联信息时发生异常。ID:" + customExtFieldRele.getId() );
|
|
|
result.error(exception);
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
}
|
|
@@ -84,51 +100,53 @@ public class ActionSave extends BaseAction {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
- if( projectExtFieldRele_old == null ) { //新建
|
|
|
|
|
- fieldName = projectExtFieldReleQueryService.getNextUseableExtFieldName( projectExtFieldRele.getProjectId(), projectExtFieldRele.getDisplayType() );
|
|
|
|
|
|
|
+ if( customExtFieldRele_old == null ) { //新建
|
|
|
|
|
+ fieldName = customExtFieldReleQueryService.getNextUseableExtFieldName( customExtFieldRele.getCorrelationId(), customExtFieldRele.getDisplayType() );
|
|
|
}else {
|
|
}else {
|
|
|
//判断是否属性在富文本和普通 文本之间发生了变换
|
|
//判断是否属性在富文本和普通 文本之间发生了变换
|
|
|
- if( ("RICHTEXT".equals( wi.getDisplayType() ) && !"RICHTEXT".equals( projectExtFieldRele_old.getDisplayType() ))
|
|
|
|
|
- || !"RICHTEXT".equals( wi.getDisplayType() ) && "RICHTEXT".equals( projectExtFieldRele_old.getDisplayType() ) ) {
|
|
|
|
|
|
|
+ if( (StringUtils.equals("RICHTEXT",wi.getDisplayType()) && !StringUtils.equals("RICHTEXT",customExtFieldRele_old.getDisplayType()))
|
|
|
|
|
+ || !StringUtils.equals("RICHTEXT",wi.getDisplayType()) && StringUtils.equals("RICHTEXT",customExtFieldRele_old.getDisplayType())) {
|
|
|
//判断当前所需要的类型的备用属性是否足够
|
|
//判断当前所需要的类型的备用属性是否足够
|
|
|
- fieldName = projectExtFieldReleQueryService.getNextUseableExtFieldName( projectExtFieldRele.getProjectId(), projectExtFieldRele.getDisplayType() );
|
|
|
|
|
|
|
+ fieldName = customExtFieldReleQueryService.getNextUseableExtFieldName( customExtFieldRele.getCorrelationId(), customExtFieldRele.getDisplayType() );
|
|
|
}else {
|
|
}else {
|
|
|
- fieldName = projectExtFieldRele_old.getExtFieldName();
|
|
|
|
|
|
|
+ fieldName = customExtFieldRele_old.getExtFieldName();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
if( StringUtils.isEmpty( fieldName )) {
|
|
if( StringUtils.isEmpty( fieldName )) {
|
|
|
//备用属性已经用完了,无法再添加新的属性
|
|
//备用属性已经用完了,无法再添加新的属性
|
|
|
check = false;
|
|
check = false;
|
|
|
- Exception exception = new ProjectExtFieldRelePersistException( "扩展属性不足,系统无法为该项目分配["+ projectExtFieldRele.getDisplayType() +"]。" );
|
|
|
|
|
- result.error(exception);
|
|
|
|
|
|
|
+ wo.setUseable(false);
|
|
|
|
|
+ /*Exception exception = new CustomExtFieldRelePersistException( "扩展属性不足(备用属性已用完),系统无法为该对象分配["+ customExtFieldRele.getDisplayType() +"]。" );
|
|
|
|
|
+ result.error(exception);*/
|
|
|
}else {
|
|
}else {
|
|
|
- projectExtFieldRele.setExtFieldName( fieldName );
|
|
|
|
|
|
|
+ customExtFieldRele.setExtFieldName( fieldName );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- projectExtFieldRele = projectExtFieldRelePersistService.save( projectExtFieldRele, effectivePerson );
|
|
|
|
|
|
|
+ customExtFieldRele = customExtFieldRelePersistService.save( customExtFieldRele, effectivePerson );
|
|
|
|
|
|
|
|
// 更新缓存
|
|
// 更新缓存
|
|
|
- ApplicationCache.notify( ProjectExtFieldRele.class );
|
|
|
|
|
|
|
+ ApplicationCache.notify( CustomExtFieldRele.class );
|
|
|
|
|
|
|
|
- wo.setId( projectExtFieldRele.getId() );
|
|
|
|
|
|
|
+ wo.setId( customExtFieldRele.getId() );
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
check = false;
|
|
|
- Exception exception = new ProjectExtFieldRelePersistException(e, "项目扩展属性关联信息保存时发生异常。");
|
|
|
|
|
|
|
+ Exception exception = new CustomExtFieldRelePersistException(e, "扩展属性关联信息保存时发生异常。");
|
|
|
result.error(exception);
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
if( Boolean.TRUE.equals( check ) ){
|
|
|
try {
|
|
try {
|
|
|
- Dynamic dynamic = dynamicPersistService.projectExtFieldReleSaveDynamic(projectExtFieldRele_old, projectExtFieldRele, effectivePerson);
|
|
|
|
|
|
|
+ Dynamic dynamic = dynamicPersistService.projectExtFieldReleSaveDynamic(customExtFieldRele_old, customExtFieldRele, effectivePerson);
|
|
|
if( dynamic != null ) {
|
|
if( dynamic != null ) {
|
|
|
List<WoDynamic> dynamics = new ArrayList<>();
|
|
List<WoDynamic> dynamics = new ArrayList<>();
|
|
|
dynamics.add( WoDynamic.copier.copy( dynamic ) );
|
|
dynamics.add( WoDynamic.copier.copy( dynamic ) );
|
|
@@ -148,23 +166,26 @@ public class ActionSave extends BaseAction {
|
|
|
|
|
|
|
|
@FieldDescribe("ID,为空时为新建")
|
|
@FieldDescribe("ID,为空时为新建")
|
|
|
private String id;
|
|
private String id;
|
|
|
-
|
|
|
|
|
- @FieldDescribe("项目ID(必填)")
|
|
|
|
|
- private String projectId;
|
|
|
|
|
|
|
|
|
|
@FieldDescribe("显示属性名称(必填)")
|
|
@FieldDescribe("显示属性名称(必填)")
|
|
|
private String displayName;
|
|
private String displayName;
|
|
|
|
|
|
|
|
@FieldDescribe("显示方式:TEXT|RADIO|CHECKBOX|SELECT|MUTISELECT|RICHTEXT(必填)")
|
|
@FieldDescribe("显示方式:TEXT|RADIO|CHECKBOX|SELECT|MUTISELECT|RICHTEXT(必填)")
|
|
|
private String displayType="TEXT";
|
|
private String displayType="TEXT";
|
|
|
|
|
+
|
|
|
|
|
+ @FieldDescribe("类型:project|task(必填)")
|
|
|
|
|
+ private String type;
|
|
|
|
|
|
|
|
@FieldDescribe("说明信息(非必填)")
|
|
@FieldDescribe("说明信息(非必填)")
|
|
|
private String description;
|
|
private String description;
|
|
|
|
|
+
|
|
|
|
|
+ @FieldDescribe("关联ID((非必填)")
|
|
|
|
|
+ private String correlationId;
|
|
|
|
|
|
|
|
@FieldDescribe("选择荐的备选数据,数据Json, displayType=RADIO|CHECKBOX|SELECT|MUTISELECT时必须填写,否则无选择项")
|
|
@FieldDescribe("选择荐的备选数据,数据Json, displayType=RADIO|CHECKBOX|SELECT|MUTISELECT时必须填写,否则无选择项")
|
|
|
private String optionsData;
|
|
private String optionsData;
|
|
|
|
|
|
|
|
- public static WrapCopier<Wi, ProjectExtFieldRele> copier = WrapCopierFactory.wi( Wi.class, ProjectExtFieldRele.class, null, null );
|
|
|
|
|
|
|
+ public static WrapCopier<Wi, CustomExtFieldRele> copier = WrapCopierFactory.wi( Wi.class, CustomExtFieldRele.class, null, null );
|
|
|
|
|
|
|
|
public String getDisplayType() {
|
|
public String getDisplayType() {
|
|
|
return displayType;
|
|
return displayType;
|
|
@@ -190,12 +211,12 @@ public class ActionSave extends BaseAction {
|
|
|
this.id = id;
|
|
this.id = id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String getProjectId() {
|
|
|
|
|
- return projectId;
|
|
|
|
|
|
|
+ public String getCorrelationId() {
|
|
|
|
|
+ return correlationId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void setProjectId(String projectId) {
|
|
|
|
|
- this.projectId = projectId;
|
|
|
|
|
|
|
+ public void setCorrelationId(String correlationId) {
|
|
|
|
|
+ this.correlationId = correlationId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getDisplayName() {
|
|
public String getDisplayName() {
|
|
@@ -205,6 +226,14 @@ public class ActionSave extends BaseAction {
|
|
|
public void setDisplayName(String displayName) {
|
|
public void setDisplayName(String displayName) {
|
|
|
this.displayName = displayName;
|
|
this.displayName = displayName;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public String getType() {
|
|
|
|
|
+ return type;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setType(String type) {
|
|
|
|
|
+ this.type = type;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
public String getDescription() {
|
|
|
return description;
|
|
return description;
|
|
@@ -219,6 +248,17 @@ public class ActionSave extends BaseAction {
|
|
|
|
|
|
|
|
@FieldDescribe("操作引起的动态内容")
|
|
@FieldDescribe("操作引起的动态内容")
|
|
|
List<WoDynamic> dynamics = new ArrayList<>();
|
|
List<WoDynamic> dynamics = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ @FieldDescribe("备用属性是否可用")
|
|
|
|
|
+ Boolean useable = true;
|
|
|
|
|
+
|
|
|
|
|
+ public Boolean getUseable(){
|
|
|
|
|
+ return useable;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setUseable(Boolean useable){
|
|
|
|
|
+ this.useable = useable;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public List<WoDynamic> getDynamics() {
|
|
public List<WoDynamic> getDynamics() {
|
|
|
return dynamics;
|
|
return dynamics;
|