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);
}
}
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;
}
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;
}
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);
}
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());
}
Aggregations