-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new component to show workflow tasks assigned to user
- Loading branch information
1 parent
db97e40
commit 255d4aa
Showing
6 changed files
with
116 additions
and
18 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
modules/api/src/main/java/org/eclipse/xpanse/api/config/TaskStatusEnumConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
*/ | ||
|
||
package org.eclipse.xpanse.api.config; | ||
|
||
import org.eclipse.xpanse.modules.models.workflow.TaskStatus; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Bean for serializing string in request parameters to TaskStatus enum. | ||
*/ | ||
@Component | ||
public class TaskStatusEnumConverter implements Converter<String, TaskStatus> { | ||
|
||
@Override | ||
public TaskStatus convert(String status) { | ||
return TaskStatus.getByValue(status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
modules/models/src/main/java/org/eclipse/xpanse/modules/models/workflow/TaskStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
*/ | ||
|
||
package org.eclipse.xpanse.modules.models.workflow; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.eclipse.xpanse.modules.models.common.exceptions.UnsupportedEnumValueException; | ||
|
||
/** | ||
* Task Status enums. | ||
*/ | ||
public enum TaskStatus { | ||
DONE("done"), | ||
FAILED("failed"); | ||
|
||
private final String status; | ||
|
||
TaskStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
/** | ||
* For Category deserialize. | ||
*/ | ||
@JsonCreator | ||
public static TaskStatus getByValue(String status) { | ||
for (TaskStatus taskStatus : values()) { | ||
if (StringUtils.equalsIgnoreCase(taskStatus.status, status)) { | ||
return taskStatus; | ||
} | ||
} | ||
throw new UnsupportedEnumValueException( | ||
String.format("Category value %s is not supported.", status)); | ||
} | ||
|
||
/** | ||
* For Category serialize. | ||
*/ | ||
@JsonValue | ||
public String toValue() { | ||
return this.status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters