use of com.pratilipi.data.client.EventData in project pratilipi by Pratilipi.
the class EventApi method get.
@Get
public Response get(GetRequest request) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
Event event = dataAccessor.getEvent(request.eventId);
EventData eventData = EventDataUtil.createEventData(event, true);
return new Response(eventData);
}
use of com.pratilipi.data.client.EventData in project pratilipi by Pratilipi.
the class EventApi method post.
@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
Gson gson = new Gson();
EventData eventData = gson.fromJson(gson.toJson(request), EventData.class);
eventData = EventDataUtil.saveEventData(eventData);
return new Response(eventData);
}
use of com.pratilipi.data.client.EventData in project pratilipi by Pratilipi.
the class PratilipiSite method createDataModelForEventsPage.
public Map<String, Object> createDataModelForEventsPage(Language language, boolean basicMode) throws InsufficientAccessException, UnexpectedServerException {
EventData eventData = new EventData();
eventData.setLanguage(language);
boolean hasAccessToAdd = EventDataUtil.hasAccessToAddEventData(eventData);
EventListApi.GetRequest request = new EventListApi.GetRequest();
request.setLanguage(language);
EventListApi.GetResponse eventListResponse = ApiRegistry.getApi(EventListApi.class).get(request);
Map<String, Object> dataModel = new HashMap<String, Object>();
dataModel.put("title", SEOTitleUtil.getEventsPageTitle(language));
dataModel.put("hasAccessToAdd", hasAccessToAdd);
if (basicMode) {
dataModel.put("eventList", eventListResponse.getEventList());
} else {
dataModel.put("eventListJson", new Gson().toJson(eventListResponse.getEventList()));
}
return dataModel;
}
use of com.pratilipi.data.client.EventData in project pratilipi by Pratilipi.
the class EventDataUtil method createEventDataList.
public static List<EventData> createEventDataList(List<Event> eventList) {
List<Long> eventIdList = new ArrayList<>();
for (Event event : eventList) eventIdList.add(event.getId());
Map<Long, Page> eventPages = DataAccessorFactory.getDataAccessor().getPages(PageType.EVENT, eventIdList);
List<EventData> eventDataList = new ArrayList<>();
for (Event event : eventList) eventDataList.add(createEventData(event, eventPages.get(event.getId()), false));
return eventDataList;
}
use of com.pratilipi.data.client.EventData in project pratilipi by Pratilipi.
the class EventDataUtil method createEventData.
public static EventData createEventData(Event event, Page eventPage, Boolean includePratilipiList) {
EventData eventData = new EventData();
eventData.setId(event.getId());
eventData.setName(event.getName());
eventData.setNameEn(event.getNameEn());
eventData.setLanguage(event.getLanguage());
eventData.setDescription(event.getDescription());
eventData.setPageUrl(eventPage.getUriAlias() == null ? eventPage.getUri() : eventPage.getUriAlias());
eventData.setBannerImageUrl(createEventBannerUrl(event));
eventData.setAccessToUpdate(hasAccessToUpdateEventData(event, null));
if (includePratilipiList) {
eventData.setPratilipiIdList(event.getPratilipiIdList());
if (event.getPratilipiIdList() == null || event.getPratilipiIdList().size() == 0) {
eventData.setPratilipiUrlList(new ArrayList<String>(0));
} else {
Map<Long, Page> pratilipiPages = DataAccessorFactory.getDataAccessor().getPages(PageType.PRATILIPI, event.getPratilipiIdList());
List<String> pratilipiUrlList = new ArrayList<>(event.getPratilipiIdList().size());
for (Long pratilipiId : event.getPratilipiIdList()) {
Page pratilipiPage = pratilipiPages.get(pratilipiId);
if (pratilipiPage != null)
pratilipiUrlList.add(pratilipiPage.getUriAlias() == null ? pratilipiPage.getUri() : pratilipiPage.getUriAlias());
}
eventData.setPratilipiUrlList(pratilipiUrlList);
}
}
return eventData;
}
Aggregations