use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class ValidateV2RC4Identifiers method testPerson.
/**
* <external-identifier:external-identifiers>
<external-identifier:external-identifier visibility="public" put-code="1">
<common:external-id-type>type-1</common:external-id-type>
<common:external-id-value>value-1</common:external-id-value>
<common:external-id-url>http://url.com/1</common:external-id-url>
<common:created-date>2001-12-31T12:00:00</common:created-date>
<common:last-modified-date>2001-12-31T12:00:00</common:last-modified-date>
<common:source>
<common:source-orcid>
<common:uri>http://orcid.org/8888-8888-8888-8880</common:uri>
<common:path>8888-8888-8888-8880</common:path>
<common:host>orcid.org</common:host>
</common:source-orcid>
<common:source-name />
</common:source>
</external-identifier:external-identifier>
</external-identifier:external-identifiers>
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPerson() throws SAXException, IOException, JAXBException, ParserConfigurationException {
Person person = unmarshallFromPath("/record_2.0_rc4/samples/person-2.0_rc4.xml", Person.class);
assertEquals("credit-name", person.getName().getCreditName().getContent());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier id = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertEquals("type-1", id.getType());
assertEquals("value-1", id.getValue());
assertEquals(new Url("http://url.com/1"), id.getUrl());
assertNull(id.getRelationship());
assertNotNull(id.getCreatedDate().getValue());
assertNotNull(id.getLastModifiedDate().getValue());
assertEquals(new Long(1), id.getPutCode());
assertEquals(Visibility.PUBLIC, id.getVisibility());
Validator validator = getValidator("person");
validator.validate(marshall(Person.class, person));
validator.validate(marshallToDOM(Person.class, person));
}
use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class WorksController method initializeFields.
private void initializeFields(WorkForm w) {
if (w.getVisibility() == null) {
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility v = profile.getActivitiesVisibilityDefault() == null ? Visibility.fromValue(OrcidVisibilityDefaults.WORKS_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault();
w.setVisibility(v);
}
if (w.getTitle() == null) {
w.setTitle(new Text());
}
if (w.getSubtitle() == null) {
w.setSubtitle(new Text());
}
if (w.getTranslatedTitle() == null) {
TranslatedTitleForm tt = new TranslatedTitleForm();
tt.setContent(new String());
tt.setLanguageCode(new String());
tt.setLanguageName(new String());
w.setTranslatedTitle(tt);
}
if (PojoUtil.isEmpty(w.getJournalTitle())) {
Text jt = new Text();
jt.setRequired(false);
w.setJournalTitle(jt);
}
if (PojoUtil.isEmpty(w.getWorkCategory())) {
Text wCategoryText = new Text();
wCategoryText.setValue(new String());
wCategoryText.setRequired(true);
w.setWorkCategory(wCategoryText);
}
if (PojoUtil.isEmpty(w.getWorkType())) {
Text wTypeText = new Text();
wTypeText.setValue(new String());
wTypeText.setRequired(true);
w.setWorkType(wTypeText);
}
initializePublicationDate(w);
if (w.getWorkExternalIdentifiers() == null || w.getWorkExternalIdentifiers().isEmpty()) {
WorkExternalIdentifier wei = new WorkExternalIdentifier();
Text wdiType = new Text();
wdiType.setValue(new String());
wei.setWorkExternalIdentifierId(new Text());
wei.setWorkExternalIdentifierType(wdiType);
wei.setRelationship(Text.valueOf(Relationship.SELF.value()));
List<WorkExternalIdentifier> wdiL = new ArrayList<WorkExternalIdentifier>();
wdiL.add(wei);
w.setWorkExternalIdentifiers(wdiL);
}
if (PojoUtil.isEmpty(w.getUrl())) {
w.setUrl(new Text());
}
if (w.getContributors() == null || w.getContributors().isEmpty()) {
List<Contributor> contrList = new ArrayList<Contributor>();
w.setContributors(contrList);
}
if (PojoUtil.isEmpty(w.getShortDescription())) {
w.setShortDescription(new Text());
}
if (PojoUtil.isEmpty(w.getLanguageCode())) {
Text lc = new Text();
lc.setRequired(false);
w.setLanguageCode(lc);
}
if (PojoUtil.isEmpty(w.getLanguageName())) {
Text ln = new Text();
ln.setRequired(false);
w.setLanguageName(ln);
}
if (PojoUtil.isEmpty(w.getCountryCode())) {
w.setCountryCode(new Text());
}
if (PojoUtil.isEmpty(w.getCountryName())) {
w.setCountryName(new Text());
}
}
use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class AddressManagerImpl method updateAddress.
@Override
@Transactional
public Address updateAddress(String orcid, Long putCode, Address address, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
AddressEntity updatedEntity = addressDao.getAddress(orcid, putCode);
Visibility originalVisibility = Visibility.fromValue(updatedEntity.getVisibility().value());
//Save the original source
String existingSourceId = updatedEntity.getSourceId();
String existingClientSourceId = updatedEntity.getClientSourceId();
//If it is an update from the API, check the source and preserve the original visibility
if (isApiRequest) {
orcidSecurityManager.checkSource(updatedEntity);
}
// Validate the address
PersonValidator.validateAddress(address, sourceEntity, false, isApiRequest, originalVisibility);
// Validate it is not duplicated
List<AddressEntity> existingAddresses = addressDao.getAddresses(orcid, getLastModified(orcid));
for (AddressEntity existing : existingAddresses) {
//If it is not the same element
if (!existing.getId().equals(address.getPutCode())) {
if (isDuplicated(existing, address, sourceEntity)) {
Map<String, String> params = new HashMap<String, String>();
params.put("type", "address");
params.put("value", address.getCountry().getValue().value());
throw new OrcidDuplicatedElementException(params);
}
}
}
adapter.toAddressEntity(address, updatedEntity);
updatedEntity.setLastModified(new Date());
//Be sure it doesn't overwrite the source
updatedEntity.setSourceId(existingSourceId);
updatedEntity.setClientSourceId(existingClientSourceId);
addressDao.merge(updatedEntity);
return adapter.toAddress(updatedEntity);
}
use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class AddressManagerImpl method setIncomingPrivacy.
private void setIncomingPrivacy(AddressEntity entity, ProfileEntity profile) {
org.orcid.jaxb.model.common_v2.Visibility incomingCountryVisibility = entity.getVisibility();
org.orcid.jaxb.model.common_v2.Visibility defaultCountryVisibility = (profile.getActivitiesVisibilityDefault() == null) ? org.orcid.jaxb.model.common_v2.Visibility.PRIVATE : org.orcid.jaxb.model.common_v2.Visibility.fromValue(profile.getActivitiesVisibilityDefault().value());
if (profile.getClaimed() != null && profile.getClaimed()) {
entity.setVisibility(defaultCountryVisibility);
} else if (incomingCountryVisibility == null) {
entity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
}
use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class ExternalIdentifierManagerImpl method setIncomingPrivacy.
private void setIncomingPrivacy(ExternalIdentifierEntity entity, ProfileEntity profile) {
org.orcid.jaxb.model.common_v2.Visibility incomingExternalIdentifierVisibility = entity.getVisibility();
org.orcid.jaxb.model.common_v2.Visibility defaultExternalIdentifierVisibility = (profile.getActivitiesVisibilityDefault() == null) ? org.orcid.jaxb.model.common_v2.Visibility.PRIVATE : org.orcid.jaxb.model.common_v2.Visibility.fromValue(profile.getActivitiesVisibilityDefault().value());
if (profile.getClaimed() != null && profile.getClaimed()) {
entity.setVisibility(defaultExternalIdentifierVisibility);
} else if (incomingExternalIdentifierVisibility == null) {
entity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
}
Aggregations