Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBPM-5757 - Replace status List<Integer> with List<Status> in CaseRun…
…timeDataService operations (#781)
- Loading branch information
1 parent
bb5efe8
commit 0877c9f
Showing
5 changed files
with
300 additions
and
69 deletions.
There are no files selected for viewing
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
70 changes: 70 additions & 0 deletions
70
jbpm-case-mgmt/jbpm-case-mgmt-api/src/main/java/org/jbpm/casemgmt/api/model/CaseStatus.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,70 @@ | ||
package org.jbpm.casemgmt.api.model; | ||
|
||
/* | ||
* Copyright 2016 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public enum CaseStatus { | ||
OPEN(1, "open"), | ||
CLOSED(2, "closed"), | ||
CANCELLED(3, "cancelled"); | ||
|
||
private final int id; | ||
private final String name; | ||
|
||
CaseStatus( int id, String name ) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public int getId() { return id; } | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static CaseStatus fromId( int id ) { | ||
switch ( id ) { | ||
case 1 : return OPEN; | ||
case 2 : return CLOSED; | ||
case 3 : return CANCELLED; | ||
default: return null; | ||
} | ||
} | ||
|
||
public static CaseStatus fromName( String name ) { | ||
if ("open".equalsIgnoreCase( name )) { | ||
return OPEN; | ||
} else if ("closed".equalsIgnoreCase( name )) { | ||
return CLOSED; | ||
} else if ("cancelled".equalsIgnoreCase( name )) { | ||
return CANCELLED; | ||
} else { | ||
return valueOf(name); | ||
} | ||
} | ||
|
||
public static List<CaseStatus> fromIdList( List<Integer> idList ) { | ||
return idList != null ? idList.stream().map(event -> fromId( event )).collect(Collectors.toList()) : null; | ||
} | ||
|
||
public static List<CaseStatus> fromNameList( List<String> nameList ) { | ||
return nameList != null ? nameList.stream().map(event -> fromName( event )).collect(Collectors.toList()) : null; | ||
} | ||
} | ||
|
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
Oops, something went wrong.