-
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#1378 added java example to show simple way to define and update…
… table in vuu
- Loading branch information
Showing
8 changed files
with
128 additions
and
84 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
37 changes: 37 additions & 0 deletions
37
example/main-java/src/main/java/org/finos/vuu/module/JavaExampleModule.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.finos.vuu.module; | ||
|
||
import org.finos.toolbox.time.Clock; | ||
import org.finos.vuu.api.ColumnBuilder; | ||
import org.finos.vuu.api.TableDef; | ||
import org.finos.vuu.core.module.DefaultModule; | ||
import org.finos.vuu.core.module.ModuleFactory; | ||
import org.finos.vuu.core.module.TableDefContainer; | ||
import org.finos.vuu.core.module.ViewServerModule; | ||
import org.finos.vuu.person.PersonProvider; | ||
import org.finos.vuu.person.PersonStore; | ||
|
||
import java.util.List; | ||
|
||
import static org.finos.vuu.util.ScalaCollectionConverter.toScalaSeq; | ||
|
||
public class JavaExampleModule extends DefaultModule { | ||
|
||
public static final String NAME = "JAVA_EXAMPLE"; | ||
|
||
public ViewServerModule create(final TableDefContainer tableDefContainer, Clock clock) { | ||
return ModuleFactory.withNamespace(NAME, tableDefContainer) | ||
.addTable(TableDef.apply( | ||
"Person", | ||
"id", | ||
new ColumnBuilder() | ||
.addString("Id") | ||
.addString("Name") | ||
.addInt("Account") | ||
.build(), | ||
toScalaSeq(List.of()) | ||
), | ||
(table, vs) -> new PersonProvider(table, new PersonStore(), clock) | ||
).asModule(); | ||
} | ||
|
||
} |
30 changes: 0 additions & 30 deletions
30
example/main-java/src/main/java/org/finos/vuu/module/MyExampleModule.java
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
example/main-java/src/main/java/org/finos/vuu/module/MyExampleProvider.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
example/main-java/src/main/java/org/finos/vuu/person/Person.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,14 @@ | ||
package org.finos.vuu.person; | ||
|
||
public class Person { | ||
|
||
public String Id; | ||
public String Name; | ||
public Integer AccountNumber; | ||
|
||
public Person(String id, String name, Integer accountNumber) { | ||
Id = id; | ||
Name = name; | ||
AccountNumber = accountNumber; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
example/main-java/src/main/java/org/finos/vuu/person/PersonProvider.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,60 @@ | ||
package org.finos.vuu.person; | ||
|
||
import org.finos.toolbox.time.Clock; | ||
import org.finos.vuu.core.table.DataTable; | ||
import org.finos.vuu.core.table.RowWithData; | ||
import org.finos.vuu.provider.Provider; | ||
|
||
import java.util.Map; | ||
|
||
public class PersonProvider implements Provider { | ||
|
||
private final DataTable table; | ||
private final PersonStore personStore; | ||
private final Clock clock; | ||
|
||
public PersonProvider(final DataTable table, PersonStore personStore, Clock clock){ | ||
this.table = table; | ||
this.personStore = personStore; | ||
this.clock = clock; | ||
} | ||
|
||
@Override | ||
public void doStart() { | ||
|
||
for (Person person : personStore.GetAll()) { | ||
var row = new RowWithData(person.Id, Map.of( "Id", person.Id, "Name", person.Name, "Account", person.AccountNumber)); | ||
table.processUpdate(person.Id, row , clock.now()); | ||
} | ||
} | ||
|
||
@Override | ||
public void doStop() { | ||
|
||
} | ||
|
||
@Override | ||
public void doInitialize() { | ||
|
||
} | ||
|
||
@Override | ||
public void doDestroy() { | ||
|
||
} | ||
|
||
@Override | ||
public String lifecycleId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Provider.super.toString(); | ||
} | ||
|
||
@Override | ||
public void subscribe(String key) { | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
example/main-java/src/main/java/org/finos/vuu/person/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.finos.vuu.person; | ||
|
||
public class PersonStore { | ||
|
||
public Person[] GetAll() { | ||
return new Person[] { | ||
new Person("uniqueId1", "Adam", 56440), | ||
new Person("uniqueId2", "Natalie", 41687) | ||
}; | ||
} | ||
} |
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