-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finos#1434 adding java example for implementing custom rpc handler fo…
…r the view port - work in progress
- Loading branch information
Showing
6 changed files
with
64 additions
and
7 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
51 changes: 51 additions & 0 deletions
51
example/main-java/src/main/java/org/finos/vuu/person/PersonRpcHandler.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,51 @@ | ||
package org.finos.vuu.person; | ||
|
||
import org.finos.vuu.core.table.DataTable; | ||
import org.finos.vuu.core.table.TableContainer; | ||
import org.finos.vuu.net.rpc.*; | ||
import scala.Function1; | ||
|
||
import java.util.Arrays; | ||
|
||
/* Work in Progress - do not use this as example yet | ||
* */ | ||
public class PersonRpcHandler extends DefaultRpcHandler { | ||
private final DataTable table; | ||
|
||
public PersonRpcHandler(DataTable table, TableContainer tableContainer) { | ||
this.table = table; | ||
|
||
registerRpc("UpdateName", (params) -> processUpdateNameRpcRequest(params)); | ||
registerRpc("GetPeopleWithName", (params) -> processGetPeopleNameRpcRequest(params)); | ||
} | ||
|
||
private void registerRpc(String functionName, Function1<RpcParams, RpcMethodCallResult> handlerFunc) { | ||
this.registerRpcMethodHandler(functionName, new RpcFunctionMethodHandler(handlerFunc)); | ||
} | ||
|
||
public RpcMethodCallResult processUpdateNameRpcRequest(RpcParams params) { | ||
updateName( | ||
params.namedParams().get("Id").get().toString(), //how to report error when expected param missing or fail to cast to right type | ||
params.namedParams().get("Name").get().toString() | ||
); | ||
return new RpcMethodSuccess(""); //how to control what viewport action to trigger? | ||
} | ||
|
||
public RpcMethodCallResult processGetPeopleNameRpcRequest(RpcParams params) { | ||
getPeopleWithNameThatStartWith( | ||
Arrays.stream(params.params()).findFirst().toString() | ||
); | ||
return new RpcMethodSuccess(""); //need to return result | ||
} | ||
|
||
public String[] updateName(String id, String newName) { | ||
//get person data from data source, update name, save to datasource? | ||
//should update table row or allow lifecycle sync to pick up change? | ||
return new String[0]; | ||
} | ||
|
||
public String[] getPeopleWithNameThatStartWith(String search) { | ||
return new String[0]; | ||
} | ||
} | ||
|
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
4 changes: 3 additions & 1 deletion
4
...ava/org/finos/vuu/person/PersonStore.java → ...os/vuu/person/datasource/PersonStore.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
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