Foros de discusión

Relationships between entitys with serviceBuilder

Marc Weisenburger, modificado hace 8 años.

Relationships between entitys with serviceBuilder

New Member Mensajes: 5 Fecha de incorporación: 7/04/15 Mensajes recientes
Hello I'm really new in Liferay.

In my project I want to consume JSON-Datas an write them in our database.
My JSON looks like:

{
  "expand" : "schema,names",
  "issues" : [
    {
      "expand" : "operations,editmeta,changelog,transitions,renderedFields",
      "fields" : {
        "creator" : {
          "displayName" : "Daniel",
          "active" : true,
          "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/user?username=stda1024",
          "name" : "da1000"
        },
        "summary" : "Guide ersellen wie man einen Service Builder erstellt",
        "resolutiondate" : null,
        "updated" : "2015-05-28T14:14:03.000+0200",
        "assignee" : {
          "displayName" : "Daniel",
          "active" : true,
          "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/user?username=stda1024",
          "name" : "da1000"
        },
        "project" : {
          "id" : "10006",
          "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/project/10006",
          "key" : "HWB",
          "name" : "HSKA WI - Bewertung"
        },
        "status" : {
          "iconUrl" : "http://www.iwi.hs-karlsruhe.de/awpjira/images/icons/statuses/inprogress.png",
          "id" : "3",
          "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/status/3",
          "description" : "This issue is being actively worked on at the moment by the assignee.",
          "name" : "In Progress"
        },
        "reporter" : {
          "displayName" : "Daniel",
          "active" : true,
          "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/user?username=stda1024",
          "name" : "da1000"
        },
      },
      "id" : "11133",
      "self" : "http://www.iwi.hs-karlsruhe.de/awpjira/rest/api/2/issue/11133",
      "key" : "HWB-143"
    },


Here I'm having an creator an an assignee. Both Persons are the Same.
In the Table field I wan't to have an foreign key to my "Jira_User" tables.
How can implement this scenario with the serviceBuilder?

Another question is, what is the best way to parse JSON into my database.
Actually I'm getting an JsonObject and get from this all my attributes manually.

Very thankfully,
Marc
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Relationships between entitys with serviceBuilder

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
The column(s) in the table which refer to the Jira_User must match the primary key(s). SB won't populate the columns for you, you'd have to look up the creator and assignee to get the users and put the keys into the record for this entity, but it will work.

For JSON, there's plenty of OXM tools available for you, pick one that has the features you need. I usually fall back to XStream because it typically just works, but you do end up doing some coding to help the marshaling.