Search in sources :

Example 6 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project ORCID-Source by ORCID.

the class ClientManagerReadOnlyTest method getClientsTest.

@Test
public void getClientsTest() {
    String seed1 = RandomStringUtils.randomAlphanumeric(30);
    String seed2 = RandomStringUtils.randomAlphanumeric(30);
    String seed3 = RandomStringUtils.randomAlphanumeric(30);
    List<ClientDetailsEntity> clients = new ArrayList<ClientDetailsEntity>();
    clients.add(getClientDetailsEntity(seed1));
    clients.add(getClientDetailsEntity(seed2));
    clients.add(getClientDetailsEntity(seed3));
    when(daoMock.findByGroupId(anyString())).thenReturn(clients);
    Set<Client> results = clientManagerReadOnly.getClients("anything");
    assertEquals(3, results.size());
    for (Client client : results) {
        if (client.getId().equals(seed1)) {
            assertEquals(getClient(seed1), client);
        } else if (client.getId().equals(seed2)) {
            assertEquals(getClient(seed2), client);
        } else if (client.getId().equals(seed3)) {
            assertEquals(getClient(seed3), client);
        } else {
            fail("Unknown id " + client.getId());
        }
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Client(org.orcid.jaxb.model.v3.dev1.client.Client) Test(org.junit.Test)

Example 7 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project ORCID-Source by ORCID.

the class ClientManagerReadOnlyTest method getClient.

private Client getClient(String randomString) {
    Client client = new Client();
    client.setAllowAutoDeprecate(true);
    client.setPersistentTokensEnabled(true);
    client.setClientType(ClientType.CREATOR);
    client.setDescription("description " + randomString);
    client.setGroupProfileId("group-profile-id " + randomString);
    client.setId(randomString);
    client.setName("client-name " + randomString);
    client.setWebsite("client-website " + randomString);
    client.setAuthenticationProviderId("authentication-provider-id " + randomString);
    Set<ClientRedirectUri> clientRedirectUris = new HashSet<ClientRedirectUri>();
    ClientRedirectUri rUri1 = new ClientRedirectUri();
    Set<ScopePathType> scopes1 = new HashSet<ScopePathType>();
    scopes1.add(ScopePathType.ACTIVITIES_READ_LIMITED);
    rUri1.setPredefinedClientScopes(scopes1);
    rUri1.setRedirectUri("redirect-uri-1 " + randomString);
    rUri1.setRedirectUriType("type-1 " + randomString);
    rUri1.setUriActType("uri-act-type-1 " + randomString);
    rUri1.setUriGeoArea("uri-geo-area-1 " + randomString);
    ClientRedirectUri rUri2 = new ClientRedirectUri();
    Set<ScopePathType> scopes2 = new HashSet<ScopePathType>();
    scopes2.add(ScopePathType.ACTIVITIES_UPDATE);
    rUri2.setPredefinedClientScopes(scopes2);
    rUri2.setRedirectUri("redirect-uri-2 " + randomString);
    rUri2.setRedirectUriType("type-2 " + randomString);
    rUri2.setUriActType("uri-act-type-2 " + randomString);
    rUri2.setUriGeoArea("uri-geo-area-2 " + randomString);
    ClientRedirectUri rUri3 = new ClientRedirectUri();
    Set<ScopePathType> scopes3 = new HashSet<ScopePathType>();
    scopes3.add(ScopePathType.AFFILIATIONS_CREATE);
    rUri3.setPredefinedClientScopes(scopes3);
    rUri3.setRedirectUri("redirect-uri-3 " + randomString);
    rUri3.setRedirectUriType("type-3 " + randomString);
    rUri3.setUriActType("uri-act-type-3 " + randomString);
    rUri3.setUriGeoArea("uri-geo-area-3 " + randomString);
    clientRedirectUris.add(rUri1);
    clientRedirectUris.add(rUri2);
    clientRedirectUris.add(rUri3);
    client.setClientRedirectUris(clientRedirectUris);
    return client;
}
Also used : ClientRedirectUri(org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri) ScopePathType(org.orcid.jaxb.model.message.ScopePathType) Client(org.orcid.jaxb.model.v3.dev1.client.Client) HashSet(java.util.HashSet)

Example 8 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project ORCID-Source by ORCID.

the class MembersManagerImpl method getMember.

@Override
@Transactional
public Member getMember(String memberId) {
    Member member = new Member();
    String orcid = memberId;
    if (!OrcidStringUtils.isValidOrcid(memberId)) {
        Map<String, String> ids = emailManager.findOricdIdsByCommaSeparatedEmails(memberId);
        // Check if it is using the email
        if (ids != null && ids.containsKey(memberId)) {
            orcid = ids.get(memberId);
        } else {
            // Check if can find it by name
            try {
                orcid = profileEntityManager.findByCreditName(memberId);
            } catch (Exception e) {
                member.getErrors().add(getMessage("manage_member.email_not_found"));
                orcid = null;
            }
        }
    }
    if (PojoUtil.isEmpty(orcid)) {
        member.getErrors().add(getMessage("manage_member.email_not_found"));
    } else {
        if (profileEntityManager.orcidExists(orcid)) {
            MemberType groupType = profileEntityManager.getGroupType(orcid);
            if (groupType != null) {
                ProfileEntity memberProfile = profileDao.find(orcid);
                member = Member.fromProfileEntity(memberProfile);
                Set<Client> clients = clientManagerReadOnly.getClients(orcid);
                List<org.orcid.pojo.ajaxForm.Client> clientsList = new ArrayList<org.orcid.pojo.ajaxForm.Client>();
                clients.forEach(c -> {
                    clientsList.add(org.orcid.pojo.ajaxForm.Client.fromModelObject(c));
                });
                member.setClients(clientsList);
            } else {
                member.getErrors().add(getMessage("manage_members.orcid_is_not_a_member"));
            }
        } else {
            member.getErrors().add(getMessage("manage_members.orcid_doesnt_exists"));
        }
    }
    return member;
}
Also used : ArrayList(java.util.ArrayList) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) MemberType(org.orcid.jaxb.model.clientgroup.MemberType) Client(org.orcid.jaxb.model.v3.dev1.client.Client) Member(org.orcid.pojo.ajaxForm.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project ORCID-Source by ORCID.

the class NotificationManagerImpl method findPermissionsByOrcidAndClient.

@Override
@Transactional(readOnly = true)
public NotificationPermissions findPermissionsByOrcidAndClient(String orcid, String client, int firstResult, int maxResults) {
    NotificationPermissions notifications = new NotificationPermissions();
    List<Notification> notificationsForOrcidAndClient = notificationAdapter.toNotification(notificationDao.findPermissionsByOrcidAndClient(orcid, client, firstResult, maxResults));
    List<NotificationPermission> notificationPermissions = new ArrayList<>();
    notificationsForOrcidAndClient.forEach(n -> notificationPermissions.add((NotificationPermission) n));
    notifications.setNotifications(notificationPermissions);
    return notifications;
}
Also used : NotificationPermissions(org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermissions) ArrayList(java.util.ArrayList) NotificationPermission(org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermission) Notification(org.orcid.jaxb.model.v3.dev1.notification.Notification) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project ORCID-Source by ORCID.

the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkTest.

@Test
public void fromProfileWorkEntityToWorkTest() {
    // Set base url to https to ensure source URI is converted to http
    orcidUrlManager.setBaseUrl("https://testserver.orcid.org");
    WorkEntity work = getWorkEntity();
    assertNotNull(work);
    Work w = jpaJaxbWorkAdapter.toWork(work);
    assertNotNull(w);
    assertNotNull(w.getCreatedDate());
    assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getCreatedDate().getValue()));
    assertNotNull(w.getLastModifiedDate());
    assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getLastModifiedDate().getValue()));
    assertEquals(Iso3166Country.CR.value(), w.getCountry().getValue().value());
    assertEquals("work:citation", w.getWorkCitation().getCitation());
    assertEquals("work:description", w.getShortDescription());
    assertEquals("work:journalTitle", w.getJournalTitle().getContent());
    assertEquals(CitationType.BIBTEX.value(), w.getWorkCitation().getWorkCitationType().value());
    assertEquals(Long.valueOf(12345), w.getPutCode());
    assertEquals(Visibility.LIMITED.value(), w.getVisibility().value());
    assertEquals("work:title", w.getWorkTitle().getTitle().getContent());
    assertEquals("work:subtitle", w.getWorkTitle().getSubtitle().getContent());
    assertEquals("work:translatedTitle", w.getWorkTitle().getTranslatedTitle().getContent());
    assertEquals("ES", w.getWorkTitle().getTranslatedTitle().getLanguageCode());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE.value(), w.getWorkType().value());
    assertNotNull(w.getWorkExternalIdentifiers());
    assertNotNull(w.getWorkExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, w.getWorkExternalIdentifiers().getExternalIdentifier().size());
    ExternalID workExtId = w.getWorkExternalIdentifiers().getExternalIdentifier().get(0);
    assertNotNull(workExtId.getValue());
    assertEquals("123", workExtId.getValue());
    assertNotNull(workExtId.getType());
    assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
    String sourcePath = w.getSource().retrieveSourcePath();
    assertNotNull(sourcePath);
    assertEquals("APP-5555555555555555", sourcePath);
    // Identifier URIs should always be http, event if base url is https
    assertEquals("https://testserver.orcid.org/client/APP-5555555555555555", w.getSource().retriveSourceUri());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)25 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)17 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)9 Tile (org.powerbot.script.Tile)8 HashSet (java.util.HashSet)6 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)5 Rectangle (java.awt.Rectangle)4 ClientSummary (org.orcid.jaxb.model.v3.dev1.client.ClientSummary)4 DBUnitTest (org.orcid.test.DBUnitTest)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)3 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)3