-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1510 from folio-org/CIRC-2142
CIRC-2142: Merge ECS TLR feature branch into master
- Loading branch information
Showing
80 changed files
with
1,688 additions
and
426 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
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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/org/folio/circulation/domain/EcsRequestPhase.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,37 @@ | ||
package org.folio.circulation.domain; | ||
|
||
import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum EcsRequestPhase { | ||
NONE(""), | ||
PRIMARY("Primary"), | ||
SECONDARY("Secondary"); | ||
|
||
public final String value; | ||
|
||
public static EcsRequestPhase from(String value) { | ||
return Arrays.stream(values()) | ||
.filter(status -> status.nameMatches(value)) | ||
.findFirst() | ||
.orElse(NONE); | ||
} | ||
|
||
EcsRequestPhase(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public boolean nameMatches(String value) { | ||
return equalsIgnoreCase(getValue(), value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/folio/circulation/domain/SearchInstance.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,50 @@ | ||
package org.folio.circulation.domain; | ||
|
||
import static org.folio.circulation.support.json.JsonObjectArrayPropertyFetcher.mapToList; | ||
import static org.folio.circulation.support.json.JsonPropertyWriter.write; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.folio.circulation.domain.representations.ItemSummaryRepresentation; | ||
import org.folio.circulation.storage.mappers.ItemMapper; | ||
|
||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import lombok.NonNull; | ||
import lombok.ToString; | ||
import lombok.Value; | ||
|
||
@Value | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class SearchInstance { | ||
|
||
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass()); | ||
JsonObject representation; | ||
String id; | ||
@NonNull Collection<Item> items; | ||
|
||
public static SearchInstance from(JsonObject representation) { | ||
return new SearchInstance(representation, representation.getString("id"), mapItems(representation)); | ||
} | ||
|
||
private static List<Item> mapItems(JsonObject representation) { | ||
return mapToList(representation, "items", new ItemMapper()::toDomain); | ||
} | ||
|
||
public SearchInstance changeItems(Collection<Item> items) { | ||
JsonArray itemsArray = new JsonArray(); | ||
for (Item item : items) { | ||
itemsArray.add(new ItemSummaryRepresentation().createItemSummary(item)); | ||
} | ||
write(representation, "items", itemsArray); | ||
return new SearchInstance(representation, id, items); | ||
} | ||
|
||
public JsonObject toJson() { | ||
return representation; | ||
} | ||
} |
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.