Skip to content

Commit

Permalink
update add notebook attr, add DTO, fix relative service, controller
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Jan 16, 2024
1 parent 1f55f58 commit c6e1118
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.yen.FlinkRestService.Controller;

import com.yen.FlinkRestService.Service.ZeppelinService;
import com.yen.FlinkRestService.model.dto.zeppelin.AddParagraphDTO;
import com.yen.FlinkRestService.model.dto.zeppelin.AddParagraphDto;
import com.yen.FlinkRestService.model.dto.zeppelin.CreateNoteDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -16,9 +17,9 @@ public class ZeppelinController {
private ZeppelinService zeppelinService;

@PostMapping("/create")
public String createNotebook(@RequestBody String notePath){
public String createNotebook(@RequestBody CreateNoteDto createNoteDto){

String res = zeppelinService.createNote(notePath);
String res = zeppelinService.createNote(createNoteDto);
return res;
}

Expand All @@ -30,7 +31,7 @@ public void deleteNotebook(@RequestBody String notePath){

// public String addParagraph(String noteId, String title, String text)
@PostMapping("/addParagraph")
public void addParagraph(@RequestBody AddParagraphDTO addParagraphDTO) throws Exception {
public void addParagraph(@RequestBody AddParagraphDto addParagraphDTO) throws Exception {

zeppelinService.addParagraph(addParagraphDTO);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.yen.FlinkRestService.Service;

import com.yen.FlinkRestService.Client.MyZeppelinClient;
import com.yen.FlinkRestService.model.dto.zeppelin.AddParagraphDTO;
import com.yen.FlinkRestService.model.dto.zeppelin.AddParagraphDto;
import com.yen.FlinkRestService.model.dto.zeppelin.CreateNoteDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.zeppelin.client.ClientConfig;
import org.apache.zeppelin.client.NoteResult;
import org.apache.zeppelin.client.ParagraphResult;
import org.apache.zeppelin.client.ZeppelinClient;
Expand Down Expand Up @@ -39,11 +38,11 @@ public class ZeppelinService {
// }


public String createNote(String notePath){
public String createNote(CreateNoteDto createNoteDto){

String path = null;
try{
path = zeppelinClient.createNote(notePath);
path = zeppelinClient.createNote(createNoteDto.getNotePath(), createNoteDto.getInterpreterGroup());
log.info("createNote OK, notePath = " + path);
return path;
}catch (Exception e){
Expand Down Expand Up @@ -131,7 +130,7 @@ public NoteResult waitUntilNoteFinished(String noteId) throws Exception{
return null;
}

public String addParagraph(AddParagraphDTO addParagraphDTO) throws Exception{
public String addParagraph(AddParagraphDto addParagraphDTO) throws Exception{

if (addParagraphDTO.getNoteId() == null || addParagraphDTO.getNoteId().length() == 0){
throw new RuntimeException("(addParagraph) noteId can't be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AddParagraphDTO {
public class AddParagraphDto {

private String noteId;
private String title;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.yen.FlinkRestService.model.dto.zeppelin;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CreateNoteDto {

private String notePath; // notebook name
private String InterpreterGroup; // interpreter, e.g. spark, flink, python.. // TODO : replace with enums
}

0 comments on commit c6e1118

Please sign in to comment.