Search in sources :

Example 1 with Event

use of com.pratilipi.data.type.Event 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;
}
Also used : ArrayList(java.util.ArrayList) Event(com.pratilipi.data.type.Event) Page(com.pratilipi.data.type.Page) EventData(com.pratilipi.data.client.EventData)

Example 2 with Event

use of com.pratilipi.data.type.Event in project pratilipi by Pratilipi.

the class DataAccessorMockImpl method createOrUpdateEvent.

@Override
public Event createOrUpdateEvent(Event event, AuditLog auditLog) {
    if (event.getId() == null) {
        long id = 1L;
        for (Event e : EventMock.EVENT_TABLE) if (id <= e.getId())
            id = e.getId() + 1;
        ((EventEntity) event).setId(id);
    }
    return event;
}
Also used : EventEntity(com.pratilipi.data.type.gae.EventEntity) Event(com.pratilipi.data.type.Event)

Example 3 with Event

use of com.pratilipi.data.type.Event in project pratilipi by Pratilipi.

the class PratilipiListV1Api method get.

@Get
public Response get(GetRequest request) throws InsufficientAccessException, UnexpectedServerException {
    PratilipiFilter pratilipiFilter = new PratilipiFilter();
    pratilipiFilter.setAuthorId(request.authorId);
    pratilipiFilter.setLanguage(request.language);
    pratilipiFilter.setType(request.type);
    pratilipiFilter.setListName(request.listName);
    pratilipiFilter.setState(request.state);
    pratilipiFilter.setOrderByLastUpdate(request.orderByLastUpdated);
    DataListCursorTuple<PratilipiData> pratilipiListCursorTuple = PratilipiDataUtil.getPratilipiDataList(request.searchQuery, request.eventId, pratilipiFilter, request.cursor, request.offset, request.resultCount == null ? 20 : request.resultCount);
    if (UxModeFilter.isAndroidApp()) {
        DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
        for (PratilipiData pratilipiData : pratilipiListCursorTuple.getDataList()) {
            PratilipiContentDoc pcDoc = docAccessor.getPratilipiContentDoc(pratilipiData.getId());
            if (pcDoc == null)
                continue;
            pratilipiData.setIndex(pcDoc.getIndex());
        }
    }
    Response response = new Response(pratilipiListCursorTuple.getDataList(), pratilipiListCursorTuple.getCursor(), pratilipiListCursorTuple.getNumberFound());
    if (UxModeFilter.isAndroidApp() && request.eventId != null && request.cursor == null) {
        Event event = DataAccessorFactory.getDataAccessor().getEvent(request.eventId);
        response.setBannerUrl(EventDataUtil.createEventBannerUrl(event));
        response.setDescription(event.getDescription());
    }
    return response;
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) PratilipiFilter(com.pratilipi.common.util.PratilipiFilter) PratilipiData(com.pratilipi.data.client.PratilipiData) DocAccessor(com.pratilipi.data.DocAccessor) Event(com.pratilipi.data.type.Event) PratilipiContentDoc(com.pratilipi.data.type.PratilipiContentDoc) Get(com.pratilipi.api.annotation.Get)

Example 4 with Event

use of com.pratilipi.data.type.Event in project pratilipi by Pratilipi.

the class PratilipiListV2Api method get.

@Get
public Response get(GetRequest request) throws InsufficientAccessException, UnexpectedServerException {
    PratilipiFilter pratilipiFilter = new PratilipiFilter();
    pratilipiFilter.setAuthorId(request.authorId);
    pratilipiFilter.setLanguage(request.language);
    pratilipiFilter.setType(request.type);
    pratilipiFilter.setListName(request.listName);
    pratilipiFilter.setState(request.state);
    pratilipiFilter.setOrderByLastUpdate(request.orderByLastUpdated);
    DataListCursorTuple<PratilipiData> pratilipiListCursorTuple = PratilipiDataUtil.getPratilipiDataList(request.searchQuery, request.eventId, pratilipiFilter, request.cursor, request.offset, request.resultCount == null ? 20 : request.resultCount);
    // Preparing & returning response object.
    Response response = new Response(pratilipiListCursorTuple.getDataList(), pratilipiListCursorTuple.getCursor(), pratilipiListCursorTuple.getNumberFound());
    if (UxModeFilter.isAndroidApp() && request.eventId != null && request.cursor == null) {
        Event event = DataAccessorFactory.getDataAccessor().getEvent(request.eventId);
        response.setBannerUrl(EventDataUtil.createEventBannerUrl(event));
        response.setDescription(event.getDescription());
    }
    return response;
}
Also used : PratilipiFilter(com.pratilipi.common.util.PratilipiFilter) PratilipiData(com.pratilipi.data.client.PratilipiData) Event(com.pratilipi.data.type.Event) Get(com.pratilipi.api.annotation.Get)

Example 5 with Event

use of com.pratilipi.data.type.Event 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);
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) DataAccessor(com.pratilipi.data.DataAccessor) Event(com.pratilipi.data.type.Event) EventData(com.pratilipi.data.client.EventData) Get(com.pratilipi.api.annotation.Get)

Aggregations

Event (com.pratilipi.data.type.Event)9 DataAccessor (com.pratilipi.data.DataAccessor)5 Page (com.pratilipi.data.type.Page)4 Get (com.pratilipi.api.annotation.Get)3 GenericResponse (com.pratilipi.api.shared.GenericResponse)2 InsufficientAccessException (com.pratilipi.common.exception.InsufficientAccessException)2 PratilipiFilter (com.pratilipi.common.util.PratilipiFilter)2 EventData (com.pratilipi.data.client.EventData)2 PratilipiData (com.pratilipi.data.client.PratilipiData)2 AuditLog (com.pratilipi.data.type.AuditLog)2 Author (com.pratilipi.data.type.Author)2 BlogPost (com.pratilipi.data.type.BlogPost)2 Pratilipi (com.pratilipi.data.type.Pratilipi)2 Date (java.util.Date)2 Website (com.pratilipi.common.type.Website)1 BlobAccessor (com.pratilipi.data.BlobAccessor)1 DocAccessor (com.pratilipi.data.DocAccessor)1 PratilipiContentDoc (com.pratilipi.data.type.PratilipiContentDoc)1 EventEntity (com.pratilipi.data.type.gae.EventEntity)1 URL (java.net.URL)1