Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Methods implemented for retrieving calendar objects for specific user
- Loading branch information
Showing
7 changed files
with
107 additions
and
7 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/edu/itu/cavabunga/client/controller/ClientController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package edu.itu.cavabunga.client.controller; | ||
|
||
import edu.itu.cavabunga.client.service.CavabungaClientService; | ||
import edu.itu.cavabunga.client.service.ParticipantRestService; | ||
import edu.itu.cavabunga.lib.entity.Component; | ||
import edu.itu.cavabunga.lib.entity.Participant; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/") | ||
public class ClientController { | ||
@Autowired | ||
private CavabungaClientService cavabungaClientService; | ||
|
||
@GetMapping | ||
public List<Component> test(){ | ||
return this.cavabungaClientService.retrieveCalendarsByOwner("testuser"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/edu/itu/cavabunga/client/service/CavabungaClientService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package edu.itu.cavabunga.client.service; | ||
|
||
import edu.itu.cavabunga.client.exception.ClientException; | ||
import edu.itu.cavabunga.lib.entity.Component; | ||
import edu.itu.cavabunga.lib.entity.Participant; | ||
import edu.itu.cavabunga.lib.entity.component.Calendar; | ||
import lombok.Data; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Data | ||
@Service | ||
public class CavabungaClientService { | ||
private ComponentRestService componentRestService; | ||
private ParameterRestService parameterRestService; | ||
private ParticipantRestService participantRestService; | ||
private PropertyRestService propertyRestService; | ||
|
||
@Autowired | ||
public CavabungaClientService(ComponentRestService componentRestService, | ||
ParameterRestService parameterRestService, | ||
ParticipantRestService participantRestService, | ||
PropertyRestService propertyRestService){ | ||
this.componentRestService = componentRestService; | ||
this.parameterRestService = parameterRestService; | ||
this.participantRestService = participantRestService; | ||
this.propertyRestService = propertyRestService; | ||
} | ||
|
||
public List<Participant> retrieveParticipant(String userName){ | ||
try { | ||
return participantRestService.recieveParticipantFromServer("participant/" + userName, RequestMethod.GET); | ||
}catch (Exception e){ | ||
throw new ClientException("Couldnt recieve participant with username: " + userName + " ,message:" + e.getMessage()); | ||
} | ||
} | ||
|
||
public List<Component> retrieveComponentById(Long id){ | ||
try { | ||
return componentRestService.recieveComponentFromServer("component/" + id.toString(), RequestMethod.GET); | ||
}catch (Exception e){ | ||
throw new ClientException("Couldnt recieve component with id of " + id.toString() + " ,message:" + e.getMessage()); | ||
} | ||
} | ||
|
||
public List<Component> retrieveComponentsByOwner(String userName){ | ||
try { | ||
return componentRestService.recieveComponentFromServer("participant/" + userName + "/components", RequestMethod.GET); | ||
}catch (Exception e){ | ||
throw new ClientException("Coulnd recieve participants components username: " + userName + " ,message:" + e.getMessage()); | ||
} | ||
} | ||
|
||
public List<Component> retrieveCalendarsByOwner(String userName){ | ||
List<Component> calendars = new ArrayList<>(); | ||
try { | ||
for (Component c : componentRestService.recieveComponentFromServer("participant/" + userName + "/components", RequestMethod.GET)){ | ||
if(c instanceof Calendar){ | ||
calendars.add(c); | ||
} | ||
} | ||
return calendars; | ||
}catch (Exception e){ | ||
throw new ClientException("Coulnd recieve participants components username: " + userName + " ,message:" + e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters