Search in sources :

Example 1 with Item

use of net.minecraft.server.v1_7_R4.Item in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method addOrcidWorks.

@Override
@Transactional
public void addOrcidWorks(OrcidProfile updatedOrcidProfile) {
    String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath();
    OrcidProfile existingProfile = retrieveOrcidProfile(orcid);
    if (existingProfile == null) {
        throw new IllegalArgumentException("No record found for " + orcid);
    }
    OrcidWorks existingOrcidWorks = existingProfile.retrieveOrcidWorks();
    OrcidWorks updatedOrcidWorks = updatedOrcidProfile.retrieveOrcidWorks();
    Visibility workVisibilityDefault = existingProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue();
    Boolean claimed = existingProfile.getOrcidHistory().isClaimed();
    setWorkPrivacy(updatedOrcidWorks, workVisibilityDefault, claimed == null ? false : claimed);
    String amenderOrcid = sourceManager.retrieveSourceOrcid();
    addSourceToWorks(updatedOrcidWorks, amenderOrcid);
    updatedOrcidWorks = dedupeWorks(updatedOrcidWorks);
    List<OrcidWork> updatedOrcidWorksList = updatedOrcidWorks.getOrcidWork();
    checkUserCanHoldMoreElement(existingProfile.retrieveOrcidWorks(), updatedOrcidProfile.retrieveOrcidWorks());
    if (compareWorksUsingScopusWay) {
        checkForAlreadyExistingWorks(existingOrcidWorks, updatedOrcidWorksList);
        if (existingOrcidWorks != null)
            checkWorkExternalIdentifiersAreNotDuplicated(updatedOrcidWorksList, existingOrcidWorks.getOrcidWork());
        else
            checkWorkExternalIdentifiersAreNotDuplicated(updatedOrcidWorksList, null);
    } else {
        checkForAlreadyExistingWorksLegacyMode(existingOrcidWorks, updatedOrcidWorksList);
    }
    //workDao.increaseDisplayIndexOnAllElements(orcid);
    persistAddedWorks(orcid, updatedOrcidWorksList);
    profileDao.flush();
    boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled();
    if (notificationsEnabled) {
        List<Item> activities = new ArrayList<>();
        for (OrcidWork updatedWork : updatedOrcidWorksList) {
            Item activity = new Item();
            activity.setItemName(updatedWork.getWorkTitle().getTitle().getContent());
            activity.setItemType(ItemType.WORK);
            activity.setPutCode(updatedWork.getPutCode());
            activities.add(activity);
        }
        notificationManager.sendAmendEmail(existingProfile, AmendedSection.WORK, activities);
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Item(org.orcid.jaxb.model.notification.permission_v2.Item) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) ArrayList(java.util.ArrayList) Visibility(org.orcid.jaxb.model.message.Visibility) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Item

use of net.minecraft.server.v1_7_R4.Item in project ORCID-Source by ORCID.

the class ProfileFundingManagerImpl method checkSourceAndDelete.

/**
     * Deletes a given funding, if and only if, the client that requested the delete is the source of the funding
     * @param orcid
     *          the funding owner
     * @param fundingId
     *          The funding id                 
     * @return true if the funding was deleted, false otherwise
     * */
@Override
@Transactional
public boolean checkSourceAndDelete(String orcid, Long fundingId) {
    ProfileFundingEntity pfe = profileFundingDao.getProfileFunding(orcid, fundingId);
    orcidSecurityManager.checkSource(pfe);
    Item item = createItem(pfe);
    boolean result = profileFundingDao.removeProfileFunding(orcid, fundingId);
    notificationManager.sendAmendEmail(orcid, AmendedSection.FUNDING, item);
    return result;
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Item

use of net.minecraft.server.v1_7_R4.Item in project ORCID-Source by ORCID.

the class PeerReviewManagerImpl method createItem.

private Item createItem(PeerReviewEntity peerReviewEntity) {
    Item item = new Item();
    item.setItemName(peerReviewEntity.getSubjectName());
    item.setItemType(ItemType.PEER_REVIEW);
    item.setPutCode(String.valueOf(peerReviewEntity.getId()));
    return item;
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Example 4 with Item

use of net.minecraft.server.v1_7_R4.Item in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidateNotificationItems.

@Test
public void testValidateNotificationItems() {
    Item i = new Item();
    Item i2 = new Item();
    Items items = new Items();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("source-work-id");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    i.setExternalIdentifier(id1);
    i2.setExternalIdentifier(id2);
    items.getItems().add(i);
    items.getItems().add(i2);
    //both valid
    validator.validateNotificationItems(items);
    //IDS one valid, one invalid
    id2.setType("blah");
    try {
        validator.validateNotificationItems(items);
        fail("no exception thrown for invalid type");
    } catch (Exception e) {
        if (!(e instanceof ActivityIdentifierValidationException))
            throw e;
    }
    //IDS one valid, one VALID due to null (at least we have to do this if we want other tests to pass!)
    id2.setType(null);
    validator.validateNotificationItems(items);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) Test(org.junit.Test)

Example 5 with Item

use of net.minecraft.server.v1_7_R4.Item in project ORCID-Source by ORCID.

the class JpaJaxbNotificationAdapterTest method testToNotificationAmendedEntity.

@Test
public void testToNotificationAmendedEntity() {
    NotificationAmended notification = new NotificationAmended();
    notification.setNotificationType(NotificationType.AMENDED);
    Source source = new Source();
    notification.setSource(source);
    SourceClientId clientId = new SourceClientId();
    source.setSourceClientId(clientId);
    clientId.setPath("APP-5555-5555-5555-5555");
    Items activities = new Items();
    notification.setItems(activities);
    Item activity = new Item();
    activities.getItems().add(activity);
    activity.setItemType(ItemType.WORK);
    activity.setItemName("Latest Research Article");
    ExternalID extId = new ExternalID();
    activity.setExternalIdentifier(extId);
    extId.setType("doi");
    extId.setValue("1234/abc123");
    NotificationEntity notificationEntity = jpaJaxbNotificationAdapter.toNotificationEntity(notification);
    assertTrue(notificationEntity instanceof NotificationAmendedEntity);
    NotificationAmendedEntity notificationAmendedEntity = (NotificationAmendedEntity) notificationEntity;
    assertNotNull(notificationEntity);
    assertEquals(NotificationType.AMENDED, notificationEntity.getNotificationType());
    // Source
    assertNull(notificationAmendedEntity.getSourceId());
    assertNull(notificationAmendedEntity.getClientSourceId());
    assertNull(notificationAmendedEntity.getElementSourceId());
}
Also used : NotificationAmendedEntity(org.orcid.persistence.jpa.entities.NotificationAmendedEntity) Item(org.orcid.jaxb.model.notification.permission_v2.Item) SourceClientId(org.orcid.jaxb.model.common_v2.SourceClientId) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.common_v2.Source) NotificationAmended(org.orcid.jaxb.model.notification.amended_v2.NotificationAmended) Test(org.junit.Test)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)18 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 CraftItemStack (org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)5 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ArrayList (java.util.ArrayList)3 ItemStack (net.minecraft.server.v1_7_R4.ItemStack)3 Url (org.orcid.jaxb.model.common_v2.Url)3 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)2 NBTTagCompound (net.minecraft.server.v1_7_R4.NBTTagCompound)2 NBTTagList (net.minecraft.server.v1_7_R4.NBTTagList)2 NBTTagString (net.minecraft.server.v1_7_R4.NBTTagString)2 ItemStack (org.bukkit.inventory.ItemStack)2 Source (org.orcid.jaxb.model.common_v2.Source)2 SourceClientId (org.orcid.jaxb.model.common_v2.SourceClientId)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 NotificationAmended (org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)2 AuthorizationUrl (org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl)2 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)2 NotificationAddItemsEntity (org.orcid.persistence.jpa.entities.NotificationAddItemsEntity)2