Home › Forum › Nuclos Entwicklung › Schnittstellen › CRUD (user made) entities from Java code
- Dieses Thema hat 5 Antworten und 4 Teilnehmer, und wurde zuletzt aktualisiert vor 12 Jahre, 4 Monaten von
Ramin Goettlich.
-
AutorBeiträge
-
11 Oktober 2010 um 14:58 Uhr #2611
Carsten Hof
TeilnehmerHello,
i would like to ask which is the best way and what Java APIs to use
to read/update entities (modules?) that are normally created by users
from the Nuclos user interface.
I think a brief description of the important classes/methods
would be enough to help me get started.
I intend to add my code to the client side and i can’t just use
the RuleInterfaceThank you in advance,
Vagelis Savvas
29 Oktober 2010 um 12:03 Uhr #2662Carsten Hof
TeilnehmerVielleicht nochmal auf deutsch:
Die Frage ist, welche Klassen im Nuclos-Code man verwenden kann (quasi als API/DB-Abstraktionsschicht), um auf die Datenbank-Entitäten zuzugreifen, die vom Benutzer über die Nuclos-Oberfläche erstellt wurden?
Wir arbeiten an Erweiterungen im Nuclos Client-Code und müssen Daten aus der Datenbank abfragen/ändern. Wir sind für jeden Hinweis dankbar (Klassen-/Methodennamen reichen aus)!
Beste Grüße,
Thilo Stadelmann10 November 2010 um 15:23 Uhr #2736Alpha Alpha
TeilnehmerHello,
you can use the MasterDataFacadeBean and/or GenericObjectFacadeBean to access the entities. The functionality is similar to the RuleInterface, i.e. most data accessor methods of the RuleInterface delegate to one of both facades (see RuleInterfaceFacadeBean). On the client side, you get an instance of the facade’s remote interface via ServiceLocator.getInstance().getFacade(XXXRemote.class).
The following list gives a short overview of the most important CRUD methods:
MasterDataFacadeRemote:
– MasterDataVO create(String entity, MasterDataVO mdvo, DependantMasterDataMap mpDependants): creates a new master data record
– MasterDataVO get(String entity, Object oId): gets the master data value object for the given id
– Collection getMasterDataIds(String entity): gets the ids of all masterdata objects
– Collection getMasterDataIds(String entity, CollectableSearchExpression cse): gets the ids of all masterdata objects that match a given search expression (ordered, when necessary)
– modify(String entity, MasterDataVO mdvo, DependantMasterDataMap mpDependants): modifies an existing master data record.
– remove(String entity, MasterDataVO mdvo, boolean removeDependants): deletes an existing master data recordGenericObjectFacadeRemote:
– GenericObjectVO create(GenericObjectWithDependantsVO gowdvo): creates a new generic object, along with its dependants.
– GenericObjectVO get(Integer genericObjectId): gets the generic object for the given id
– List getGenericObjectIds(Integer moduleId, CollectableSearchExpression cse): gets the ids of all leased objects that match a given search expression (ordered, when necessary)
– GenericObjectWithDependantsVO modify(Integer moduleId, GenericObjectWithDependantsVO gowdvo): updates an existing generic object and returns the written object along with its dependants.
– remove(GenericObjectWithDependantsVO gowdvo, boolean deletePhysically): delete a generic objectWhich to use depends on whether the entity has a state model (GenericObject) or not (MasterData). Please note that this dichotomy will be removed in a future version of Nuclos and both facades will be replaced with a unified service.
Best regards,
alpha22 November 2010 um 16:16 Uhr #2759Carsten Hof
TeilnehmerVielen Dank, die Erklärung war sehr hilfreich.
Nun müsste ich eine Entität persistieren, die Referenzfelder zu anderen Entitäten hat.
Bsp: Eine Adress-Entität hat eine Referenz zu einem Land. Wie muss die Referenz gehandhabt werden, wenn eine neue Adresse gespeichert wird?Ein kurzes Beispiel würde mir sehr weiterhelfen. Danke!
Noch eine Frage: Ist es in Bezug auf die Antwortzeiten günstiger, wenn wir auf Deutsch fragen oder spielt das keine Rolle?
29 November 2010 um 17:40 Uhr #2781Claudia Mangstl
TeilnehmerHallo !
Die Sprache spielt keine Rolle, eher die Komplexität der Frage und/oder die eigene Auslastung 😉
Eine Antwort folgt…
3 Januar 2011 um 16:44 Uhr #2931Ramin Goettlich
TeilnehmerMögliche Beispiele für diesen Fall:
> a. persisting a new Person
Map fields = new HashMap();
fields.put("personName", "My Name");
fields.put("personAddressId", );
MasterDataVO mdvo = new MasterDataVO(fields);
MasterDataDelegate.getInstance().create("Person", mdvo, null);
If you want to create a new Person with a new Address, you must first create the Address object and then the Person object with the ID of the newly created Address object.
Note: For a record with dependant data (like nuclos_report), the create() method takes a third parameter with a DependantMasterDataMap. This map would contain the records of your subentity (e.g. the nuclos_reportoutput records).
> b. modifying and persisting an existing one
The same here.
mdvo = MasterDataDelegate.getInstance().get("Person", personId);
String oldName = mdvo.getField("personName", String.class);
mdvo.setField("personName", "New name");
MasterDataDelegate.getInstance().update("Person", mdvo, null);
-
AutorBeiträge