use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testStripHtmlFromNames.
@Test
public void testStripHtmlFromNames() throws NoSuchRequestHandlingMethodException {
RecordNameManager mockRecordNameManager = Mockito.mock(RecordNameManager.class);
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
TargetProxyHelper.injectIntoProxy(controller, "recordNameManager", mockRecordNameManager);
when(mockRecordNameManager.exists(Mockito.anyString())).thenReturn(true);
NamesForm nf = new NamesForm();
nf.setCreditName(Text.valueOf("<button onclick=\"alert('hello')\">Credit Name</button>"));
nf.setGivenNames(Text.valueOf("<button onclick=\"alert('hello')\">Given Names</button>"));
nf.setFamilyName(Text.valueOf("<button onclick=\"alert('hello')\">Family Name</button>"));
nf.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PUBLIC));
nf = controller.setNameFormJson(nf);
assertEquals("Credit Name", nf.getCreditName().getValue());
assertEquals("Given Names", nf.getGivenNames().getValue());
assertEquals("Family Name", nf.getFamilyName().getValue());
Name name = new Name();
name.setCreditName(new CreditName("Credit Name"));
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
name.setVisibility(Visibility.PUBLIC);
verify(mockRecordNameManager, times(1)).updateRecordName(Mockito.eq(USER_ORCID), Mockito.eq(name));
}
use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getNameMapperFacade.
public MapperFacade getNameMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Name, RecordNameEntity> nameClassMap = mapperFactory.classMap(Name.class, RecordNameEntity.class);
addV3DateFields(nameClassMap);
nameClassMap.field("creditName.content", "creditName");
nameClassMap.field("givenNames.content", "givenNames");
nameClassMap.field("familyName.content", "familyName");
nameClassMap.field("path", "profile.id");
nameClassMap.byDefault();
nameClassMap.register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.
the class RecordNameManagerV3Test method testCreateRecordName.
@Test
public void testCreateRecordName() {
Name name = new Name();
long time = System.currentTimeMillis();
name.setCreditName(new CreditName("Credit Name " + time));
name.setFamilyName(new FamilyName("Family Name " + time));
name.setGivenNames(new GivenNames("Given Names " + time));
name.setVisibility(Visibility.PRIVATE);
String orcid = "0000-0000-0000-0005";
recordNameManager.createRecordName(orcid, name);
Name newName = recordNameManager.getRecordName(orcid);
assertNotNull(newName);
assertEquals("Credit Name " + time, newName.getCreditName().getContent());
assertEquals("Family Name " + time, newName.getFamilyName().getContent());
assertEquals("Given Names " + time, newName.getGivenNames().getContent());
assertEquals(Visibility.PRIVATE, newName.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createName.
protected Name createName(Visibility v) {
Name name = new Name();
name.setVisibility(v);
name.setCreditName(new CreditName("Credit Name"));
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
return name;
}
use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method clearRecord.
/**
* Clears all record info but the email addresses, that stay unmodified
*/
private void clearRecord(String orcid, Boolean disableTokens) {
// Remove works
workManager.removeAllWorks(orcid);
// Remove funding
fundingManager.removeAllFunding(orcid);
// Remove affiliations
affiliationsManager.removeAllAffiliations(orcid);
// Remove peer reviews
peerReviewManager.removeAllPeerReviews(orcid);
// Remove addresses
addressManager.removeAllAddress(orcid);
// Remove external identifiers
externalIdentifierManager.removeAllExternalIdentifiers(orcid);
// Remove researcher urls
researcherUrlManager.removeAllResearcherUrls(orcid);
// Remove other names
otherNameManager.removeAllOtherNames(orcid);
// Remove keywords
profileKeywordManager.removeAllKeywords(orcid);
// Remove biography
if (biographyManager.exists(orcid)) {
Biography deprecatedBio = new Biography();
deprecatedBio.setContent(null);
deprecatedBio.setVisibility(Visibility.PRIVATE);
biographyManager.updateBiography(orcid, deprecatedBio);
}
// Set the deactivated names
if (recordNameManager.exists(orcid)) {
Name name = new Name();
name.setCreditName(new CreditName());
name.setGivenNames(new GivenNames("Given Names Deactivated"));
name.setFamilyName(new FamilyName("Family Name Deactivated"));
name.setVisibility(Visibility.PUBLIC);
name.setPath(orcid);
recordNameManager.updateRecordName(orcid, name);
}
//
userConnectionDao.deleteByOrcid(orcid);
if (disableTokens) {
// Disable any token that belongs to this record
orcidOauth2TokenDetailService.disableAccessTokenByUserOrcid(orcid, RevokeReason.RECORD_DEACTIVATED);
}
// Change default visibility to private
profileDao.updateDefaultVisibility(orcid, org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
Aggregations