Search in sources :

Example 1 with Item

use of net.minecraft.server.v1_9_R2.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 2 with Item

use of net.minecraft.server.v1_9_R2.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)

Example 3 with Item

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

the class JpaJaxbNotificationAdapterTest method testToNotificationPermissionEntity.

@Test
public void testToNotificationPermissionEntity() {
    NotificationPermission notification = new NotificationPermission();
    notification.setNotificationType(NotificationType.PERMISSION);
    String authorizationUrlString = "https://orcid.org/oauth/authorize?client_id=APP-U4UKCNSSIM1OCVQY&response_type=code&scope=/orcid-works/create&redirect_uri=http://somethirdparty.com";
    AuthorizationUrl url = new AuthorizationUrl();
    notification.setAuthorizationUrl(url);
    notification.setNotificationIntro("This is the intro");
    notification.setNotificationSubject("This is the subject");
    Source source = new Source();
    notification.setSource(source);
    SourceClientId clientId = new SourceClientId();
    source.setSourceClientId(clientId);
    clientId.setPath("APP-5555-5555-5555-5555");
    url.setUri(authorizationUrlString);
    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 NotificationAddItemsEntity);
    NotificationAddItemsEntity addActivitiesEntity = (NotificationAddItemsEntity) notificationEntity;
    assertNotNull(notificationEntity);
    assertEquals(NotificationType.PERMISSION, notificationEntity.getNotificationType());
    assertEquals(authorizationUrlString, addActivitiesEntity.getAuthorizationUrl());
    assertEquals(notification.getNotificationIntro(), notificationEntity.getNotificationIntro());
    assertEquals(notification.getNotificationSubject(), notificationEntity.getNotificationSubject());
    // Source
    assertNull(notificationEntity.getSourceId());
    assertNull(notificationEntity.getClientSourceId());
    assertNull(notificationEntity.getElementSourceId());
    Set<NotificationItemEntity> activityEntities = addActivitiesEntity.getNotificationItems();
    assertNotNull(activityEntities);
    assertEquals(1, activityEntities.size());
    NotificationItemEntity activityEntity = activityEntities.iterator().next();
    assertEquals(ItemType.WORK, activityEntity.getItemType());
    assertEquals("Latest Research Article", activityEntity.getItemName());
    assertEquals("DOI", activityEntity.getExternalIdType());
    assertEquals("1234/abc123", activityEntity.getExternalIdValue());
}
Also used : AuthorizationUrl(org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl) NotificationAddItemsEntity(org.orcid.persistence.jpa.entities.NotificationAddItemsEntity) 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) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Items(org.orcid.jaxb.model.notification.permission_v2.Items) NotificationItemEntity(org.orcid.persistence.jpa.entities.NotificationItemEntity) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.common_v2.Source) Test(org.junit.Test)

Example 4 with Item

use of net.minecraft.server.v1_9_R2.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 = null;
    List<OrcidWork> updatedOrcidWorksList = null;
    try {
        synchronized (getLock(orcid)) {
            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);
            if (updatedOrcidWorks != null) {
                addSourceToWorks(updatedOrcidWorks, getSource());
            }
            updatedOrcidWorks = dedupeWorks(updatedOrcidWorks);
            updatedOrcidWorksList = updatedOrcidWorks.getOrcidWork();
            checkUserCanHoldMoreElement(existingProfile.retrieveOrcidWorks(), updatedOrcidProfile.retrieveOrcidWorks());
            if (compareWorksUsingScopusWay) {
                checkForAlreadyExistingWorks(orcid, existingOrcidWorks, updatedOrcidWorksList);
                if (existingOrcidWorks != null)
                    checkWorkExternalIdentifiersAreNotDuplicated(updatedOrcidWorksList, existingOrcidWorks.getOrcidWork());
                else
                    checkWorkExternalIdentifiersAreNotDuplicated(updatedOrcidWorksList, null);
            } else {
                checkForAlreadyExistingWorksLegacyMode(existingOrcidWorks, updatedOrcidWorksList);
            }
            persistAddedWorks(orcid, updatedOrcidWorksList);
            profileDao.flush();
        }
    } finally {
        releaseLock(orcid);
    }
    boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled();
    if (notificationsEnabled && updatedOrcidWorksList != null) {
        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(orcid, 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 5 with Item

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

the class ProfileFundingManagerImpl method createItemList.

private List<Item> createItemList(ProfileFundingEntity profileFundingEntity) {
    Item item = new Item();
    item.setItemName(profileFundingEntity.getTitle());
    item.setItemType(ItemType.FUNDING);
    item.setPutCode(String.valueOf(profileFundingEntity.getId()));
    return Arrays.asList(item);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)8 CraftItemStack (org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack)8 ItemStack (org.bukkit.inventory.ItemStack)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ArrayList (java.util.ArrayList)4 ItemStack (net.minecraft.server.v1_9_R2.ItemStack)3 NBTTagList (net.minecraft.server.v1_9_R2.NBTTagList)3 NBTTagString (net.minecraft.server.v1_9_R2.NBTTagString)3 Url (org.orcid.jaxb.model.common_v2.Url)3 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)2 ListTag (com.wasteofplastic.org.jnbt.ListTag)2 StringTag (com.wasteofplastic.org.jnbt.StringTag)2 Tag (com.wasteofplastic.org.jnbt.Tag)2 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)2 Font (java.awt.Font)2 Point (java.awt.Point)2 Map (java.util.Map)2