Search in sources :

Example 21 with GoToMeeting

use of org.olat.modules.gotomeeting.GoToMeeting in project openolat by klemens.

the class GoToTrainingWebService method getTrainings.

/**
 * returns the list of booking of the resource.
 *
 * @response.representation.200.qname {http://www.example.com}goToTrainingVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc This is the list of all training of a resource
 * @response.representation.200.example {@link org.olat.modules.gotomeeting.restapi.Examples#SAMPLE_GoToTrainingVO}
 * @return The list of trainings
 */
@GET
@Path("trainings")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTrainings() {
    try {
        List<GoToMeeting> meetings = meetingManager.getMeetings(GoToType.training, entry, subIdentifier, null);
        GoToTrainingVO[] bookingVos = new GoToTrainingVO[meetings.size()];
        int count = 0;
        for (GoToMeeting meeting : meetings) {
            bookingVos[count++] = new GoToTrainingVO(meeting);
        }
        return Response.ok(bookingVos).build();
    } catch (Exception e) {
        log.error("", e);
        return handleUnexpectedException();
    }
}
Also used : GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 22 with GoToMeeting

use of org.olat.modules.gotomeeting.GoToMeeting in project OpenOLAT by OpenOLAT.

the class GoToRegistrantDAOTest method createRegistrant.

@Test
public void createRegistrant() {
    String token = UUID.randomUUID().toString();
    Identity trainee = JunitTestHelper.createAndPersistIdentityAsRndUser("trainee-2");
    GoToOrganizer organizer = organizerDao.createOrganizer(null, token, token, token, null, null, null, null, 10l, null);
    Assert.assertNotNull(organizer);
    Date start = new Date();
    Date end = new Date();
    String trainingKey = Long.toString(CodeHelper.getForeverUniqueID());
    GoToMeeting training = meetingDao.createTraining("New training", null, "Very interessant", trainingKey, start, end, organizer, null, null, null);
    dbInstance.commit();
    // create registrant
    String registrantKey = Long.toString(CodeHelper.getForeverUniqueID());
    String joinUrl = "http://openolat.com/join/" + registrantKey;
    String confirmUrl = "http://openolat.com/confirm/" + registrantKey;
    GoToRegistrant registrant = registrantDao.createRegistrant(training, trainee, registrantKey, joinUrl, confirmUrl);
    Assert.assertNotNull(registrant);
    dbInstance.commit();
    // load
    GoToRegistrant reloadRegistrant = registrantDao.getRegistrant(training, trainee);
    Assert.assertNotNull(reloadRegistrant);
    Assert.assertEquals(registrant, reloadRegistrant);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting) GoToRegistrant(org.olat.modules.gotomeeting.GoToRegistrant) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 23 with GoToMeeting

use of org.olat.modules.gotomeeting.GoToMeeting in project OpenOLAT by OpenOLAT.

the class GoToTrainingWebService method saveTraining.

private Response saveTraining(GoToTrainingVO training) {
    try {
        GoToMeeting meeting = null;
        GoToError error = new GoToError();
        if (training.getKey() == null) {
            boolean organizerFound = false;
            List<GoToOrganizer> organizers = meetingManager.getSystemOrganizers();
            for (GoToOrganizer organizer : organizers) {
                boolean available = meetingManager.checkOrganizerAvailability(organizer, training.getStart(), training.getEnd());
                if (available) {
                    meeting = meetingManager.scheduleTraining(organizer, training.getName(), training.getExternalId(), "-", training.getStart(), training.getEnd(), entry, subIdentifier, null, error);
                    organizerFound = true;
                    if (!error.hasError()) {
                        break;
                    }
                }
            }
            if (!organizerFound) {
                error.setError(GoToErrors.OrganizerOverlap);
            }
        } else {
            meeting = meetingManager.getMeetingByExternalId(training.getExternalId());
            if (meeting == null) {
                List<GoToOrganizer> organizers = meetingManager.getSystemOrganizers();
                for (GoToOrganizer organizer : organizers) {
                    meeting = meetingManager.scheduleTraining(organizer, training.getName(), training.getExternalId(), "-", training.getStart(), training.getEnd(), entry, subIdentifier, null, error);
                    if (!error.hasError()) {
                        break;
                    }
                }
            } else {
                meetingManager.updateTraining(meeting, training.getName(), "-", training.getStart(), training.getEnd(), error);
            }
        }
        Response response;
        if (error.hasError()) {
            response = handleGoToTrainingError(error);
        } else if (meeting == null) {
            response = handleUnexpectedException();
        } else {
            response = Response.ok(new GoToTrainingVO(meeting)).build();
        }
        return response;
    } catch (Exception e) {
        log.error("", e);
        return handleUnexpectedException();
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Response(javax.ws.rs.core.Response) GoToError(org.olat.modules.gotomeeting.model.GoToError) GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting)

Example 24 with GoToMeeting

use of org.olat.modules.gotomeeting.GoToMeeting in project OpenOLAT by OpenOLAT.

the class GoToTrainingWebService method getTrainings.

/**
 * returns the list of booking of the resource.
 *
 * @response.representation.200.qname {http://www.example.com}goToTrainingVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc This is the list of all training of a resource
 * @response.representation.200.example {@link org.olat.modules.gotomeeting.restapi.Examples#SAMPLE_GoToTrainingVO}
 * @return The list of trainings
 */
@GET
@Path("trainings")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTrainings() {
    try {
        List<GoToMeeting> meetings = meetingManager.getMeetings(GoToType.training, entry, subIdentifier, null);
        GoToTrainingVO[] bookingVos = new GoToTrainingVO[meetings.size()];
        int count = 0;
        for (GoToMeeting meeting : meetings) {
            bookingVos[count++] = new GoToTrainingVO(meeting);
        }
        return Response.ok(bookingVos).build();
    } catch (Exception e) {
        log.error("", e);
        return handleUnexpectedException();
    }
}
Also used : GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 25 with GoToMeeting

use of org.olat.modules.gotomeeting.GoToMeeting in project OpenOLAT by OpenOLAT.

the class GoToMeetingsEditController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addTrainingButton == source) {
        doAddTraining(ureq);
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("delete".equals(se.getCommand())) {
                GoToMeeting meeting = tableModel.getObject(se.getIndex());
                doConfirmDelete(ureq, meeting);
            } else if ("edit".equals(se.getCommand())) {
                GoToMeeting meeting = tableModel.getObject(se.getIndex());
                doEditTraining(ureq, meeting);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Aggregations

GoToMeeting (org.olat.modules.gotomeeting.GoToMeeting)34 Date (java.util.Date)20 GoToOrganizer (org.olat.modules.gotomeeting.GoToOrganizer)18 Test (org.junit.Test)16 RepositoryEntry (org.olat.repository.RepositoryEntry)10 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 Identity (org.olat.core.id.Identity)4 GoToRegistrant (org.olat.modules.gotomeeting.GoToRegistrant)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Response (javax.ws.rs.core.Response)2 HttpResponse (org.apache.http.HttpResponse)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 JSONObject (org.json.JSONObject)2