Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #12409 > unrolled thread

Java Webflux R2dbc

Started byZaur Farrukzada <zaurfarrukzada55@gmail.com>
First post2021-03-23 05:02 -0700
Last post2022-01-05 00:34 -0800
Articles 2 — 2 participants

Back to article view | Back to comp.programming


Contents

  Java Webflux R2dbc Zaur Farrukzada <zaurfarrukzada55@gmail.com> - 2021-03-23 05:02 -0700
    Re: Java Webflux R2dbc Härra Ramob <ya12983@mail.com> - 2022-01-05 00:34 -0800

#12409 — Java Webflux R2dbc

FromZaur Farrukzada <zaurfarrukzada55@gmail.com>
Date2021-03-23 05:02 -0700
SubjectJava Webflux R2dbc
Message-ID<aa36afb0-3796-49b7-8b41-f0501b05c58dn@googlegroups.com>
Hi everyone I am write simple project in Webflux Rest api not problem the response

  This is model layer 
    
   Due class
     
         @Getter
         @Setter
         @AllArgsConstructor
         @Builder
         public class Due implements Serializable {

             @Id
             private Integer id;
             private Date my_data;
             private Boolean recurring;
             private String my_string;

           }

 Label class

           @Getter
           @Setter
           @NoArgsConstructor
           @AllArgsConstructor
           @Builder
           public class Label {

               @Id
               @Column("label_id")
               private Integer id;
               private String name;
               private Integer color;
               @Column("order_data")
               private Integer orderdata;
               private  Boolean favorite;
               @JsonIgnore
               private List<Task> tasks = new ArrayList<>();

          }

Project class

             @Getter
             @Setter
             @NoArgsConstructor
             @AllArgsConstructor
             @Builder
             public class Project {

                    @Id
                    @Column("project_id")
                    private Integer id;
                    private String name;
                    private Integer comment_count;
                    @Column("orderdata")
                    private Integer order;
                    private Integer color;
                    private Boolean shared;
                    private Boolean favorite;
                    private Boolean team_inbox;
                    private Boolean inbox_project;
                    private String url;
                    private Integer task_id;

           }

Task class
               
                @Getter
                @Setter
                @Builder
                @NoArgsConstructor
                @AllArgsConstructor
                public class Task implements Serializable {

                     @Id
                     private Integer id;
                     private Integer comment_count;
                     private Boolean completed;
                     private String  content;
                     private String  url;
                     private Integer orderdata;
                     private Integer priority;
                     private Integer due_id;
                     private List<Project> project;
                     private List<Label> labels;

            }


My Mapping TaskDto class

              
                  @Getter
                  @Setter
                  @Builder
                  public class TaskDto implements Serializable {

                          private Integer id;
                          private Integer comment_count;
                          private Boolean completed;
                          private String  content;
                          private String  url;
                          private Integer orderdata;
                          private Integer priority;
                          private Due due;
                          private List<Project> project;
                          private List<Label> labels;

                  }

 My TaskManager  


         @Component
         @RequiredArgsConstructor
         public class TaskManager {

    private final TasksRepository tasksRepository;
    private final DueRepository dueRepository;
    private final ProjectRepository projectRepository;
    private final LabelRepository labelRepository;

    public Flux<TaskDto> findAll() {

        List<Project> projectList = new ArrayList<>();
        List<Label> label_ids = new ArrayList<>();

        Flux<Task> tasks = tasksRepository.findAll();
        Flux<Due> allTasks = tasks.flatMap(task -> dueRepository.findById(task.getDue_id()));

        Due.DueBuilder newDue = Due.builder();
        Project.ProjectBuilder newProject = Project.builder();
        Label.LabelBuilder newLabel = Label.builder();
        TaskDto.TaskDtoBuilder newTask = TaskDto.builder();

        return allTasks.map(due -> newDue
                .recurring(due.getRecurring())
                .my_data(due.getMy_data())
                .my_string(due.getMy_string())
                .id(due.getId()))
                .thenMany(tasks)
                .flatMap(p -> projectRepository.findAll()
                        .map(t -> newProject.id(t.getId())
                                .color(t.getColor())
                                .comment_count(t.getComment_count())
                                .inbox_project(t.getInbox_project())
                                .order(t.getOrder())
                                .favorite(t.getFavorite())
                                .name(t.getName())
                                .shared(t.getShared())
                                .team_inbox(t.getTeam_inbox())
                                .task_id(t.getTask_id())
                                .url(t.getUrl()).build())
                        .map(projectList::add)
                        .thenMany(tasks)
                        .flatMap(l -> labelRepository.findAll())
                        .map(label -> newLabel.id(label.getId())
                                .color(label.getColor())
                                .name(label.getName())
                                .favorite(label.getFavorite())
                                .orderdata(label.getOrderdata())
                                .build())
                        .map(label_ids::add)
                        .thenMany(tasks)
                        .map(task -> newTask
                                .id(task.getId())
                                .url(task.getUrl())
                                .orderdata(task.getOrderdata())
                                .comment_count(task.getComment_count())
                                .completed(task.getCompleted())
                                .content(task.getContent())
                                .priority(task.getPriority())
                                .labels(label_ids)
                                .due(newDue.build())
                                .project(projectList).build())
                ).doOnError(System.out::println);
           }

     }
   

Response Json

       
    {
    "id": 1,
    "comment_count": 10,
    "completed": false,
    "content": "new conent",
    "url": "http.google.com",
    "orderdata": 5,
    "priority": 5,
    "due": {
      "id": 2,
      "my_data": "2021-03-23",
      "recurring": true,
      "my_string": "new string my"
    },
    "project": [
      {
        "id": 1,
        "name": "new name",
        "comment_count": 9,
        "order": 4,
        "color": 4,
        "shared": false,
        "favorite": true,
        "team_inbox": false,
        "inbox_project": true,
        "url": "http://google.com",
        "task_id": 1
      },
      {
        "id": 2,
        "name": "new name2",
        "comment_count": 6,
        "order": 3,
        "color": 3,
        "shared": false,
        "favorite": false,
        "team_inbox": false,
        "inbox_project": false,
        "url": "http://youtube.com",
        "task_id": 1
      },
      {
        "id": 3,
        "name": "new project name3",
        "comment_count": 4,
        "order": 5,
        "color": 3,
        "shared": true,
        "favorite": false,
        "team_inbox": false,
        "inbox_project": false,
        "url": "https://bbcnews.com",
        "task_id": 2
      },
      {
        "id": 1,
        "name": "new name",
        "comment_count": 9,
        "order": 4,
        "color": 4,
        "shared": false,
        "favorite": true,
        "team_inbox": false,
        "inbox_project": true,
        "url": "http://google.com",
        "task_id": 1
      },
      {
        "id": 2,
        "name": "new name2",
        "comment_count": 6,
        "order": 3,
        "color": 3,
        "shared": false,
        "favorite": false,
        "team_inbox": false,
        "inbox_project": false,
        "url": "http://youtube.com",
        "task_id": 1
      },
      {
        "id": 3,
        "name": "new project name3",
        "comment_count": 4,
        "order": 5,
        "color": 3,
        "shared": true,
        "favorite": false,
        "team_inbox": false,
        "inbox_project": false,
        "url": "https://bbcnews.com",
        "task_id": 2
      }
    ],
    "labels": [
      {
        "id": 1,
        "name": "new name label",
        "color": 5,
        "orderdata": 5,
        "favorite": false
      },
      {
        "id": 2,
        "name": "new name label2",
        "color": 3,
        "orderdata": 4,
        "favorite": true
      },
      {
        "id": 3,
        "name": "new name label3",
        "color": 5,
        "orderdata": 6,
        "favorite": false
      },
      {
        "id": 1,
        "name": "new name label",
        "color": 5,
        "orderdata": 5,
        "favorite": false
      },
      {
        "id": 2,
        "name": "new name label2",
        "color": 3,
        "orderdata": 4,
        "favorite": true
      },
      {
        "id": 3,
        "name": "new name label3",
        "color": 5,
        "orderdata": 6,
        "favorite": false
      },
      {
        "id": 1,
        "name": "new name label",
        "color": 5,
        "orderdata": 5,
        "favorite": false
      },
      {
        "id": 2,
        "name": "new name label2",
        "color": 3,
        "orderdata": 4,
        "favorite": true
      },
      {
        "id": 3,
        "name": "new name label3",
        "color": 5,
        "orderdata": 6,
        "favorite": false
      },
      {
        "id": 1,
        "name": "new name label",
        "color": 5,
        "orderdata": 5,
        "favorite": false
      },
      {
        "id": 2,
        "name": "new name label2",
        "color": 3,
        "orderdata": 4,
        "favorite": true
      },
      {
        "id": 3,
        "name": "new name label3",
        "color": 5,
        "orderdata": 6,
        "favorite": false
      }
    
    }

My problem is that the code is working, but the response is wrong, so for example the label has 3 but 6 returns, the projects are repeated, I don't understand what the problem is, you can say help and better offers

[toc] | [next] | [standalone]


#14428

FromHärra Ramob <ya12983@mail.com>
Date2022-01-05 00:34 -0800
Message-ID<3ea25f8b-e50e-40a0-9d99-7544aef1b79dn@googlegroups.com>
In reply to#12409
Hi....................

Want to make business together?



Mister Kristjan Robam
hrramob@@@@@@mail.ee

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web