Search in sources :

Example 6 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerBlImpl method updatePublicationSystem.

public PublicationSystem updatePublicationSystem(PerunSession session, PublicationSystem ps) throws CabinetException, InternalErrorException {
    PublicationSystem upps = getPublicationSystemManagerDao().updatePublicationSystem(session, ps);
    log.debug("{} updated.", upps);
    return upps;
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem)

Example 7 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationManagerBlImpl method createPublication.

// business methods --------------------------------
@Override
public Publication createPublication(PerunSession sess, Publication p) throws CabinetException, InternalErrorException {
    if (p.getCreatedDate() == null)
        p.setCreatedDate(new Date());
    p.setCreatedByUid(sess.getPerunPrincipal().getUserId());
    // check existence
    if (publicationExists(p)) {
        throw new CabinetException("Cannot create duplicate publication: " + p, ErrorCodes.PUBLICATION_ALREADY_EXISTS);
    }
    Publication createdPublication;
    if (p.getExternalId() == 0 && p.getPublicationSystemId() == 0) {
        // get internal pub. system
        PublicationSystem ps = getPublicationSystemManagerBl().getPublicationSystemByName("INTERNAL");
        // There is only one internal system so, get(0) is safe
        p.setPublicationSystemId(ps.getId());
    }
    stripLongParams(p);
    createdPublication = getPublicationManagerDao().createPublication(sess, p);
    log.debug("{} created.", createdPublication);
    return createdPublication;
}
Also used : Publication(cz.metacentrum.perun.cabinet.model.Publication) CabinetException(cz.metacentrum.perun.cabinet.bl.CabinetException) PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) Date(java.util.Date)

Example 8 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerBlImpl method createPublicationSystem.

// methods -----------------------------
public PublicationSystem createPublicationSystem(PerunSession session, PublicationSystem ps) throws InternalErrorException {
    PublicationSystem newps = getPublicationSystemManagerDao().createPublicationSystem(session, ps);
    log.debug("{} created.", newps);
    return newps;
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem)

Example 9 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemStrategyIntegrationTest method contactPublicationSystemMUTest.

@Test
public void contactPublicationSystemMUTest() throws Exception {
    System.out.println("PublicationSystemStrategyIntegrationTest.contactPublicationSystemMUTest");
    PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemByNamespace("mu");
    assertNotNull(publicationSystem);
    PublicationSystemStrategy prezentator = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
    assertNotNull(prezentator);
    String authorId = "39700";
    int yearSince = 2009;
    int yearTill = 2010;
    HttpResponse result = prezentator.execute(prezentator.getHttpRequest(authorId, yearSince, yearTill, publicationSystem));
    assertNotNull(result);
}
Also used : HttpResponse(org.apache.http.HttpResponse) PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) CabinetBaseIntegrationTest(cz.metacentrum.perun.cabinet.CabinetBaseIntegrationTest) Test(org.junit.Test)

Example 10 with PublicationSystem

use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.

the class PublicationSystemManagerIntegrationTest method getPublicationSystemById.

@Test
public void getPublicationSystemById() throws Exception {
    System.out.println("PublicationSystemManagerIntegrationTest.getPublicationSystemById");
    PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemById(pubSysZcu.getId());
    assertNotNull(publicationSystem);
    assertTrue(Objects.equals(publicationSystem, pubSysZcu));
    PublicationSystemStrategy ps = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
    assertNotNull(ps);
}
Also used : PublicationSystem(cz.metacentrum.perun.cabinet.model.PublicationSystem) PublicationSystemStrategy(cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy) Test(org.junit.Test)

Aggregations

PublicationSystem (cz.metacentrum.perun.cabinet.model.PublicationSystem)14 Test (org.junit.Test)9 CabinetException (cz.metacentrum.perun.cabinet.bl.CabinetException)3 Publication (cz.metacentrum.perun.cabinet.model.Publication)3 PublicationSystemStrategy (cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy)3 CabinetBaseIntegrationTest (cz.metacentrum.perun.cabinet.CabinetBaseIntegrationTest)2 Date (java.util.Date)2 HttpResponse (org.apache.http.HttpResponse)2 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)2 Authorship (cz.metacentrum.perun.cabinet.model.Authorship)1 Category (cz.metacentrum.perun.cabinet.model.Category)1 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1