Search in sources :

Example 26 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project camunda-bpm-platform by camunda.

the class HistoricInstanceForCleanupQueryTest method testSortHistoricBatchesForCleanup.

@SuppressWarnings("unchecked")
@Test
public void testSortHistoricBatchesForCleanup() {
    Date startDate = ClockUtil.getCurrentTime();
    int daysInThePast = -11;
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
    // given
    List<Batch> list = Arrays.asList(helper.migrateProcessInstancesAsync(1), helper.migrateProcessInstancesAsync(1), helper.migrateProcessInstancesAsync(1));
    String batchType = list.get(0).getType();
    final Map<String, Integer> batchOperationsMap = new HashedMap();
    batchOperationsMap.put(batchType, 4);
    for (Batch batch : list) {
        helper.executeSeedJob(batch);
        helper.executeJobs(batch);
        ClockUtil.setCurrentTime(DateUtils.addDays(startDate, ++daysInThePast));
        helper.executeMonitorJob(batch);
    }
    ClockUtil.setCurrentTime(new Date());
    // when
    List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
    assertEquals(3, historicList.size());
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            HistoricBatchManager historicBatchManager = commandContext.getHistoricBatchManager();
            List<String> ids = historicBatchManager.findHistoricBatchIdsForCleanup(7, batchOperationsMap);
            assertEquals(3, ids.size());
            HistoricBatchEntity instance0 = historicBatchManager.findHistoricBatchById(ids.get(0));
            HistoricBatchEntity instance1 = historicBatchManager.findHistoricBatchById(ids.get(1));
            HistoricBatchEntity instance2 = historicBatchManager.findHistoricBatchById(ids.get(2));
            assertTrue(instance0.getEndTime().before(instance1.getEndTime()));
            assertTrue(instance1.getEndTime().before(instance2.getEndTime()));
            return null;
        }
    });
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Date(java.util.Date) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) HistoricBatchEntity(org.camunda.bpm.engine.impl.batch.history.HistoricBatchEntity) List(java.util.List) HashedMap(org.apache.commons.collections.map.HashedMap) HistoricBatchManager(org.camunda.bpm.engine.impl.persistence.entity.HistoricBatchManager) Test(org.junit.Test)

Example 27 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project alliance by codice.

the class CropAdapterTest method setUp.

@Before
public void setUp() {
    this.cropAdapter = new CropAdapter();
    this.originalImage = mock(BufferedImage.class);
    this.overviewImage = mock(BufferedImage.class);
    this.args = new HashedMap();
}
Also used : HashedMap(org.apache.commons.collections.map.HashedMap) BufferedImage(java.awt.image.BufferedImage) Before(org.junit.Before)

Example 28 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project alfresco-remote-api by Alfresco.

the class CMISHttpServletRequest method getParameterMap.

@SuppressWarnings("unchecked")
@Override
public Map getParameterMap() {
    Map map = httpReq.getParameterMap();
    Map ret = new HashedMap(map);
    if (networkId != null) {
        ret.put(Constants.PARAM_REPOSITORY_ID, new String[] { networkId });
    }
    return ret;
}
Also used : HashedMap(org.apache.commons.collections.map.HashedMap) Map(java.util.Map) HashedMap(org.apache.commons.collections.map.HashedMap)

Example 29 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project topcom-cloud by 545314690.

the class ElasticSearchService method statSearch.

/**
 * 功能描述:统计查询
 * @param index 索引名
 * @param type 类型
 * @param constructor 查询构造
 * @param agg 自定义计算
 */
public Map<Object, Object> statSearch(String index, String type, ESQueryBuilderConstructor constructor, AggregationBuilder agg) {
    if (agg == null) {
        return null;
    }
    Map<Object, Object> map = new HashedMap();
    SearchRequestBuilder searchRequestBuilder = client.prepareSearch(index).setTypes(type);
    // 排序
    if (StringUtils.isNotEmpty(constructor.getAsc()))
        searchRequestBuilder.addSort(constructor.getAsc(), SortOrder.ASC);
    if (StringUtils.isNotEmpty(constructor.getDesc()))
        searchRequestBuilder.addSort(constructor.getDesc(), SortOrder.DESC);
    // 设置查询体
    if (null != constructor) {
        searchRequestBuilder.setQuery(constructor.listBuilders());
    } else {
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
    }
    int size = constructor.getSize();
    if (size < 0) {
        size = 0;
    }
    if (size > MAX) {
        size = MAX;
    }
    // 返回条目数
    searchRequestBuilder.setSize(size);
    searchRequestBuilder.setFrom(constructor.getFrom() < 0 ? 0 : constructor.getFrom());
    SearchResponse sr = searchRequestBuilder.addAggregation(agg).get();
    Terms stateAgg = sr.getAggregations().get("agg");
    Iterator<? extends Terms.Bucket> iter = stateAgg.getBuckets().iterator();
    while (iter.hasNext()) {
        Terms.Bucket gradeBucket = iter.next();
        map.put(gradeBucket.getKey(), gradeBucket.getDocCount());
    }
    return map;
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) HashedMap(org.apache.commons.collections.map.HashedMap) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 30 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project topcom-cloud by 545314690.

the class ElasticSearchService method statSearch.

/**
 * 功能描述:统计查询
 * @param index 索引名
 * @param type 类型
 * @param constructor 查询构造
 * @param groupBy 统计字段
 */
public Map<Object, Object> statSearch(String index, String type, ESQueryBuilderConstructor constructor, String groupBy) {
    Map<Object, Object> map = new HashedMap();
    SearchRequestBuilder searchRequestBuilder = client.prepareSearch(index).setTypes(type);
    // 排序
    if (StringUtils.isNotEmpty(constructor.getAsc()))
        searchRequestBuilder.addSort(constructor.getAsc(), SortOrder.ASC);
    if (StringUtils.isNotEmpty(constructor.getDesc()))
        searchRequestBuilder.addSort(constructor.getDesc(), SortOrder.DESC);
    // 设置查询体
    if (null != constructor) {
        searchRequestBuilder.setQuery(constructor.listBuilders());
    } else {
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
    }
    int size = constructor.getSize();
    if (size < 0) {
        size = 0;
    }
    if (size > MAX) {
        size = MAX;
    }
    // 返回条目数
    searchRequestBuilder.setSize(size);
    searchRequestBuilder.setFrom(constructor.getFrom() < 0 ? 0 : constructor.getFrom());
    SearchResponse sr = searchRequestBuilder.addAggregation(AggregationBuilders.terms("agg").field(groupBy)).get();
    Terms stateAgg = sr.getAggregations().get("agg");
    Iterator<? extends Terms.Bucket> iter = stateAgg.getBuckets().iterator();
    while (iter.hasNext()) {
        Terms.Bucket gradeBucket = iter.next();
        map.put(gradeBucket.getKey(), gradeBucket.getDocCount());
    }
    return map;
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) HashedMap(org.apache.commons.collections.map.HashedMap) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Aggregations

HashedMap (org.apache.commons.collections.map.HashedMap)34 Test (org.junit.Test)14 Map (java.util.Map)13 HashMap (java.util.HashMap)10 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 File (java.io.File)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 EmailPool (com.bonree.brfs.email.EmailPool)2 ManagerContralFactory (com.bonree.brfs.schedulers.ManagerContralFactory)2 Date (java.util.Date)2 List (java.util.List)2 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)2 SearchResponse (org.elasticsearch.action.search.SearchResponse)2 Terms (org.elasticsearch.search.aggregations.bucket.terms.Terms)2 OrgVO (com.bc.pmpheep.back.vo.OrgVO)1 ProductType (com.bc.pmpheep.back.vo.ProductType)1 Service (com.bonree.brfs.common.service.Service)1