Search in sources :

Example 1 with GivenNames

use of org.orcid.jaxb.model.v3.dev1.record.GivenNames 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));
}
Also used : RecordNameManager(org.orcid.core.manager.v3.RecordNameManager) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) NamesForm(org.orcid.pojo.ajaxForm.NamesForm) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test)

Example 2 with GivenNames

use of org.orcid.jaxb.model.v3.dev1.record.GivenNames 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();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) SourceName(org.orcid.jaxb.model.v3.dev1.common.SourceName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName)

Example 3 with GivenNames

use of org.orcid.jaxb.model.v3.dev1.record.GivenNames 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());
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 4 with GivenNames

use of org.orcid.jaxb.model.v3.dev1.record.GivenNames 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;
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name)

Example 5 with GivenNames

use of org.orcid.jaxb.model.v3.dev1.record.GivenNames 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);
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) Name(org.orcid.jaxb.model.v3.dev1.record.Name)

Aggregations

Name (org.orcid.jaxb.model.v3.dev1.record.Name)8 FamilyName (org.orcid.jaxb.model.v3.dev1.record.FamilyName)7 GivenNames (org.orcid.jaxb.model.v3.dev1.record.GivenNames)7 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)6 Test (org.junit.Test)4 BaseTest (org.orcid.core.BaseTest)2 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)2 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)2 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 MapperFactory (ma.glasnost.orika.MapperFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 RecordNameManager (org.orcid.core.manager.v3.RecordNameManager)1 Amount (org.orcid.jaxb.model.v3.dev1.common.Amount)1 Day (org.orcid.jaxb.model.v3.dev1.common.Day)1 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)1