-
Notifications
You must be signed in to change notification settings - Fork 4
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 #50 from OpenLiberty/findByShipSize
Adding findByShipSizeAndRank
- Loading branch information
Showing
14 changed files
with
217 additions
and
23 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
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,26 @@ | ||
package io.openliberty.sample.application; | ||
|
||
import jakarta.json.bind.annotation.JsonbTypeDeserializer; | ||
import jakarta.persistence.Embeddable; | ||
|
||
@Embeddable | ||
@JsonbTypeDeserializer(ShipDeserializer.class) | ||
public class Ship { | ||
public static enum Size { | ||
small, large | ||
} | ||
|
||
public String shipName; | ||
|
||
public Size size; | ||
|
||
Ship() { | ||
|
||
} | ||
|
||
Ship(String name, Size size) { | ||
this.shipName = name; | ||
this.size = size; | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/io/openliberty/sample/application/ShipDeserializer.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,26 @@ | ||
package io.openliberty.sample.application; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import jakarta.json.bind.serializer.DeserializationContext; | ||
import jakarta.json.bind.serializer.JsonbDeserializer; | ||
import jakarta.json.stream.JsonParser; | ||
|
||
public class ShipDeserializer implements JsonbDeserializer<Ship> { | ||
|
||
@Override | ||
public Ship deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { | ||
String shipName = parser.getString(); | ||
if (shipName.equals("Liberty Saucer")) { | ||
return new Ship(shipName, Ship.Size.small); | ||
} else if (shipName.equals("Jakarta Sailboat")) { | ||
return new Ship(shipName, Ship.Size.small); | ||
} else if (shipName.equals("WebSphere Battleship")) { | ||
return new Ship(shipName, Ship.Size.large); | ||
} else { | ||
return 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
async function refreshFindByShipSizeAndRank(shipSize, rank) { | ||
response = await fetch("db/crew/shipSize/" +shipSize+"/rank/" +rank); | ||
|
||
if (response.ok) { | ||
const doc = await response.json(); | ||
doc.forEach(addToCrewMembersFindByShipSizeAndRank); | ||
} | ||
} | ||
|
||
function addToCrewMembersFindByShipSizeAndRank(entry){ | ||
var userHtml = "<div>Name: " + entry.Name + "</div>" + | ||
"<div>ID: " + entry.CrewID + "</div>" + | ||
"<div>Ship: " + entry.Ship + "</div>"; | ||
|
||
var userDiv = document.createElement("div"); | ||
userDiv.setAttribute("class","user flexbox"); | ||
userDiv.setAttribute("id",entry.CrewID); | ||
userDiv.setAttribute("onclick","remove('"+entry.CrewID+"')"); | ||
userDiv.innerHTML=userHtml; | ||
document.getElementById("shipAndRankBoxes").appendChild(userDiv); | ||
} |
Oops, something went wrong.