Search in sources :

Example 1 with RecentService

use of com.emc.storageos.db.client.model.uimodels.RecentService in project coprhd-controller by CoprHD.

the class CatalogServiceManagerImpl method createRecentCatalogService.

@Deprecated
public void createRecentCatalogService(CatalogService catalogService, StorageOSUser user) {
    List<RecentService> recentServices = getRecentServices(user.getUserName());
    if (catalogService != null) {
        RecentService found = findRecentService(recentServices, catalogService, user);
        if (found != null) {
            // Delete and Re-Save to update Created Time
            client.delete(found);
            createRecentService(catalogService.getId(), user.getUserName());
        } else {
            cleanUpRecentServices(recentServices);
            createRecentService(catalogService.getId(), user.getUserName());
        }
    }
}
Also used : RecentService(com.emc.storageos.db.client.model.uimodels.RecentService)

Example 2 with RecentService

use of com.emc.storageos.db.client.model.uimodels.RecentService in project coprhd-controller by CoprHD.

the class CatalogServiceManagerImpl method getRecentCatalogServices.

@Deprecated
public List<CatalogService> getRecentCatalogServices(StorageOSUser user) {
    List<CatalogService> catalogServices = Lists.newArrayList();
    List<RecentService> recentServices = getRecentServices(user.getUserName());
    for (RecentService recentService : recentServices) {
        CatalogService catalogService = client.catalogServices().findById(recentService.getCatalogServiceId());
        if (catalogService != null) {
            catalogServices.add(catalogService);
        }
    }
    SortedIndexUtils.sort(catalogServices);
    return catalogServices;
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) RecentService(com.emc.storageos.db.client.model.uimodels.RecentService)

Example 3 with RecentService

use of com.emc.storageos.db.client.model.uimodels.RecentService in project coprhd-controller by CoprHD.

the class CatalogServiceManagerImpl method createRecentService.

@Deprecated
private void createRecentService(URI catalogServiceId, String username) {
    RecentService recentService = new RecentService();
    recentService.setUserId(username);
    recentService.setCatalogServiceId(catalogServiceId);
    client.save(recentService);
}
Also used : RecentService(com.emc.storageos.db.client.model.uimodels.RecentService)

Example 4 with RecentService

use of com.emc.storageos.db.client.model.uimodels.RecentService in project coprhd-controller by CoprHD.

the class ComparatorTest method testCreationTimeComparator.

@Test
public void testCreationTimeComparator() throws Exception {
    _logger.info("Starting CreationTimeComparator test");
    List<RecentService> recentServices = Lists.newArrayList();
    Calendar cal1 = Calendar.getInstance();
    RecentService rs1 = new RecentService();
    rs1.setCreationTime(cal1);
    rs1.setUserId("myUserId");
    URI csId1 = URIUtil.createId(CatalogService.class);
    rs1.setCatalogServiceId(csId1);
    recentServices.add(rs1);
    Calendar cal2 = Calendar.getInstance();
    cal2.add(Calendar.HOUR_OF_DAY, 1);
    RecentService rs2 = new RecentService();
    rs2.setCreationTime(cal2);
    rs2.setUserId("myUserId");
    URI csId2 = URIUtil.createId(CatalogService.class);
    rs2.setCatalogServiceId(csId2);
    recentServices.add(rs2);
    Calendar cal3 = Calendar.getInstance();
    cal3.add(Calendar.HOUR_OF_DAY, 2);
    RecentService rs3 = new RecentService();
    rs3.setCreationTime(cal3);
    rs3.setUserId("myUserId");
    URI csId3 = URIUtil.createId(CatalogService.class);
    rs1.setCatalogServiceId(csId3);
    recentServices.add(rs3);
    Collections.shuffle(recentServices);
    Collections.sort(recentServices, CreationTimeComparator.OLDEST_FIRST);
    Assert.assertEquals(rs1, recentServices.get(0));
    Assert.assertEquals(rs2, recentServices.get(1));
    Assert.assertEquals(rs3, recentServices.get(2));
    List<RecentService> newList = Lists.newArrayList();
    newList.add(rs2);
    newList.add(rs3);
    newList.add(rs1);
    Collections.sort(newList, new CreationTimeComparator());
    Assert.assertEquals(rs1, newList.get(0));
    Assert.assertEquals(rs2, newList.get(1));
    Assert.assertEquals(rs3, newList.get(2));
    Collections.sort(newList, CreationTimeComparator.NEWEST_FIRST);
    Assert.assertEquals(rs3, newList.get(0));
    Assert.assertEquals(rs2, newList.get(1));
    Assert.assertEquals(rs1, newList.get(2));
}
Also used : Calendar(java.util.Calendar) CreationTimeComparator(com.emc.sa.model.util.CreationTimeComparator) URI(java.net.URI) RecentService(com.emc.storageos.db.client.model.uimodels.RecentService) Test(org.junit.Test)

Aggregations

RecentService (com.emc.storageos.db.client.model.uimodels.RecentService)4 CreationTimeComparator (com.emc.sa.model.util.CreationTimeComparator)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1 URI (java.net.URI)1 Calendar (java.util.Calendar)1 Test (org.junit.Test)1