Home Forum Nuclos Entwicklung Schnittstellen CRUD (user made) entities from Java code

Ansicht von 6 Beiträgen - 1 bis 6 (von insgesamt 6)
  • Autor
    Beiträge
  • #2611
    Carsten Hof
    Teilnehmer

    Hello,

    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 RuleInterface

    Thank you in advance,

    Vagelis Savvas

    #2662
    Carsten Hof
    Teilnehmer

    Vielleicht 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 Stadelmann

    #2736
    Alpha Alpha
    Teilnehmer

    Hello,

    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 record

    GenericObjectFacadeRemote:
    – 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 object

    Which 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,
    alpha

    #2759
    Carsten Hof
    Teilnehmer

    Vielen 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?

    #2781
    Claudia Mangstl
    Teilnehmer

    Hallo !

    Die Sprache spielt keine Rolle, eher die Komplexität der Frage und/oder die eigene Auslastung 😉

    Eine Antwort folgt…

    #2931
    Ramin Goettlich
    Teilnehmer

    Mö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);

Ansicht von 6 Beiträgen - 1 bis 6 (von insgesamt 6)