org.apache.commons.collections4.map.LinkedMap Java Examples

The following examples show how to use org.apache.commons.collections4.map.LinkedMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BirtStatisticsServiceImpl.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String getDomainStatisticsUrlWithoutFormat(ComAdmin admin, String sessionId, DomainStatisticDto domainStatistic, boolean forInternalUse) throws Exception {
	Map<String, Object> map = new LinkedMap<>();

	map.put(REPORT_NAME, domainStatistic.getReportName());
	map.put(IS_SVG, true);
	map.put(COMPANY_ID, admin.getCompanyID());
	map.put(TARGET_ID, domainStatistic.getTargetId());
	map.put(MAILING_LIST_ID, domainStatistic.getMailingListId());
	map.put(MAX_DOMAINS, domainStatistic.getMaxDomainNum());
	map.put(LANGUAGE, admin.getAdminLang());
	map.put(SECURITY_TOKEN, BirtInterceptingFilter.createSecurityToken(configService, admin.getCompanyID()));
	map.put(EMM_SESSION, sessionId);
	map.put(TARGET_BASE_URL.toLowerCase(), generateTargetBaseUrl());
	map.put(IS_TOP_LEVEL_DOMAIN, domainStatistic.isTopLevelDomain());

	if (forInternalUse) {
		return generateUrlWithParamsForInternalAccess(map);
	} else {
		return generateUrlWithParamsForExternalAccess(map);
	}
}
 
Example #2
Source File: BirtStatisticsServiceImpl.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String getRecipientStatisticUrlWithoutFormat(ComAdmin admin, String sessionId, RecipientStatisticDto recipientStatistic) throws Exception {
	Map<String, Object> map = new LinkedMap<>();
	map.put(REPORT_NAME, recipientStatistic.getReportName());
	map.put(COMPANY_ID, admin.getCompanyID());
	map.put(MEDIA_TYPE, recipientStatistic.getMediaType());
	map.put(IS_SVG, true);

	SimpleDateFormat format = DateUtilities.getFormat(DateUtilities.YYYY_MM_DD, AgnUtils.getTimeZone(admin));
	DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(format.toPattern());

	LocalDate startDate = recipientStatistic.getLocaleStartDate();
	LocalDate endDate = recipientStatistic.getLocalEndDate();
	map.put(RECIPIENT_START_DATE, DateUtilities.format(startDate, dateFormatter));
	map.put(RECIPIENT_STOP_DATE, DateUtilities.format(endDate, dateFormatter));

	map.put(TARGET_ID, recipientStatistic.getTargetId());
	map.put(MAILING_LIST_ID, recipientStatistic.getMailinglistId());
	map.put(HOUR_SCALE, recipientStatistic.isHourScale());
	map.put(LANGUAGE, admin.getAdminLang());
	map.put(SECURITY_TOKEN, BirtInterceptingFilter.createSecurityToken(configService, admin.getCompanyID()));
	map.put(EMM_SESSION, sessionId);
	map.put(TARGET_BASE_URL.toLowerCase(), generateTargetBaseUrl());

	return generateUrlWithParamsForExternalAccess(map);
}
 
Example #3
Source File: BirtStatisticsServiceImpl.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String getMailingComparisonStatisticUrl(ComAdmin admin, String sessionId, MailingComparisonDto mailingComparisonDto) throws Exception {
   	Map<String, Object> map = new LinkedMap<>();
	map.put(REPORT_NAME, mailingComparisonDto.getReportName());
	map.put(COMPANY_ID, admin.getCompanyID());
	map.put(TARGET_ID, mailingComparisonDto.getTargetId());
	map.put(SELECTED_TARGETS, StringUtils.join(mailingComparisonDto.getTargetIds(), ","));
	map.put(RECIPIENTS_TYPE, mailingComparisonDto.getRecipientType());
	map.put(SELECTED_MAILINGS, StringUtils.join(mailingComparisonDto.getMailingIds(), ","));
	map.put(LANGUAGE, admin.getAdminLang());
	map.put(FORMAT, mailingComparisonDto.getReportFormat());
	map.put(SECURITY_TOKEN, BirtInterceptingFilter.createSecurityToken(configService, admin.getCompanyID()));
	map.put(EMM_SESSION, sessionId);
	map.put(TARGET_BASE_URL.toLowerCase(), generateTargetBaseUrl());
	map.put(TRACKING_ALLOWED, AgnUtils.isMailTrackingAvailable(admin));
	
	return generateUrlWithParamsForExternalAccess(map);
}
 
Example #4
Source File: ContainerGroupTableItems.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void doGroup() {
    roots = new LinkedList<>();
    parents = new LinkedHashMap<>();
    children = new LinkedHashMap<>();
    groupItems = new HashMap<>();
    itemGroups = new HashMap<>();

    for (E item : container.getItems()) {
        GroupInfo<MetaPropertyPath> groupInfo = groupItems(0, null, roots, item, new LinkedMap<>());

        if (groupInfo == null) {
            throw new IllegalStateException("Item group cannot be NULL");
        }

        List<K> itemsIds = groupItems.computeIfAbsent(groupInfo, k -> new ArrayList<>());
        itemsIds.add(item.getId());
    }
}
 
Example #5
Source File: CommonsExample.java    From pragmatic-java-engineer with GNU General Public License v3.0 6 votes vote down vote up
public static void collections() {
    List<String> list = Lists.newArrayList();
    List<String> list2 = Lists.newArrayList();

    if (CollectionUtils.isNotEmpty(list)) {
        CollectionUtils.subtract(list, list2);
        CollectionUtils.subtract(list, list2);
        CollectionUtils.retainAll(list, list2);
    }

    OrderedMap map = new LinkedMap();
    map.put("1", "1");
    map.put("2", "2");
    map.put("3", "3");
    map.firstKey();
    map.nextKey("1");
}
 
Example #6
Source File: JRDesignCrosstab.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new crosstab.
 * 
 * @param defaultStyleProvider default style provider
 */
public JRDesignCrosstab(JRDefaultStyleProvider defaultStyleProvider)
{
	super(defaultStyleProvider);
	
	parametersList = new ArrayList<JRCrosstabParameter>();
	parametersMap = new HashMap<String, JRCrosstabParameter>();
	rowGroupsMap = new HashMap<String, Integer>();
	rowGroups = new ArrayList<JRCrosstabRowGroup>();
	columnGroupsMap = new HashMap<String, Integer>();
	columnGroups = new ArrayList<JRCrosstabColumnGroup>();
	measuresMap = new HashMap<String, Integer>();
	measures = new ArrayList<JRCrosstabMeasure>();
	
	cellsMap = new HashMap<Pair<String,String>,JRCrosstabCell>();
	cellsList = new ArrayList<JRCrosstabCell>();
	
	addBuiltinParameters();
	
	variablesList = new LinkedMap<String, JRVariable>();
	addBuiltinVariables();
	
	dataset = new JRDesignCrosstabDataset();
	lineBox = new JRBaseLineBox(this);
}
 
Example #7
Source File: JRDesignCrosstab.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
	in.defaultReadObject();

	if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
	{
		runDirectionValue = RunDirectionEnum.getByValue(runDirection);
	}
	
	if (lineBox == null)
	{
		lineBox = new JRBaseLineBox(this);
	}
	
	// this will work as long as SequencedHashMap is part of commons collections
	// we could also look at PSEUDO_SERIAL_VERSION_UID
	if (variablesList.getClass().getName().equals("org.apache.commons.collections.SequencedHashMap"))
	{
		// converting to the new type
		variablesList = new LinkedMap<String, JRVariable>(variablesList);
	}
}
 
Example #8
Source File: DynamicLIRS.java    From cache2k-benchmark with Apache License 2.0 6 votes vote down vote up
public DynamicLIRS(int size, SimpleLIRS.Tuning tuning) {
  this.size = size;
  this.hirsRatio = tuning.getHirsRatio();
  this.hirsSize = (int)((double)this.size * this.hirsRatio + 0.5);
  this.lirsSize = this.size - this.hirsSize;
  this.currentHIRSSize = 0;
  this.currentLIRSSize = 0;
  this.demotedBlocks = 0;
  this.lirStack = new LinkedMap<>();
  this.hirStack = new LinkedMap<>();
  this.residentHIRList = new LinkedMap<>();
  this.nonresidentHIRsInStack = 0;
  this.totalSize = 0;
  this.totalCount = 0;
  this.totalAdjustment = 0;
  this.adjusts = 0;
}
 
Example #9
Source File: GroupDelegate.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected GroupInfo<MetaPropertyPath> groupItems(int propertyIndex, GroupInfo parent, List<GroupInfo> children,
                                                 T item, LinkedMap<MetaPropertyPath, Object> groupValues) {
    MetaPropertyPath property = (MetaPropertyPath) groupProperties[propertyIndex++];
    Object itemValue = getValueByProperty(item, property);
    groupValues.put(property, itemValue);

    GroupInfo<MetaPropertyPath> groupInfo = new GroupInfo<>(groupValues);
    itemGroups.put(item.getId(), groupInfo);

    if (!parents.containsKey(groupInfo)) {
        parents.put(groupInfo, parent);
    }

    if (!children.contains(groupInfo)) {
        children.add(groupInfo);
    }

    List<GroupInfo> groupChildren =
            this.children.computeIfAbsent(groupInfo, k -> new ArrayList<>());

    if (propertyIndex < groupProperties.length) {
        groupInfo = groupItems(propertyIndex, groupInfo, groupChildren, item, groupValues);
    }

    return groupInfo;
}
 
Example #10
Source File: LIRSWithClockProIdea.java    From cache2k-benchmark with Apache License 2.0 6 votes vote down vote up
public LIRSWithClockProIdea(int size, SimpleLIRS.Tuning tuning) {
  this.size = size;
  this.hirsRatio = tuning.getHirsRatio();
  this.hirsSize = (int)((double)this.size * this.hirsRatio + 0.5);
  this.lirsSize = this.size - this.hirsSize;
  this.currentHIRSSize = 0;
  this.currentLIRSSize = 0;
  this.demotedBlocks = 0;
  this.lirStack = new LinkedMap<>();
  this.hirStack = new LinkedMap<>();
  this.residentHIRList = new LinkedMap<>();
  this.nonresidentHIRsInStack = 0;
  this.totalSize = 0;
  this.totalCount = 0;
  this.totalAdjustment = 0;
  this.adjusts = 0;
}
 
Example #11
Source File: GroupDelegate.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void doGroup() {
    roots = new LinkedList<>();
    parents = new LinkedHashMap<>();
    children = new HashMap<>();
    groupItems = new HashMap<>();
    itemGroups = new HashMap<>();

    Collection<K> itemIds = datasource.getItemIds();
    for (K id : itemIds) {
        T item = datasource.getItem(id);
        GroupInfo<MetaPropertyPath> groupInfo = groupItems(0, null, roots, item, new LinkedMap<>());

        if (groupInfo == null) {
            throw new IllegalStateException("Item group cannot be NULL");
        }

        List<K> itemsIds = groupItems.computeIfAbsent(groupInfo, k -> new ArrayList<>());
        itemsIds.add(id);
    }
}
 
Example #12
Source File: SimpleLIRS.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
public SimpleLIRS(int size, Tuning tuning) {
  this.size = size;
  this.hirsRatio = tuning.getHirsRatio();
  this.hirsSize = (int)((double)this.size * this.hirsRatio + 0.5);
  this.lirsSize = this.size - this.hirsSize;
  this.currentHIRSSize = 0;
  this.currentLIRSSize = 0;
  this.lirStack = new LinkedMap<>();
  this.hirStack = new LinkedMap<>();
  this.residentHIRList = new LinkedMap<>();
  this.nonresidentHIRsInStack = 0;
}
 
Example #13
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenALinkedMap_whenElementRemoved_thenSizeDecrease() {
    LinkedMap<String, Integer> lmap = (LinkedMap<String, Integer>) this.runnersLinkedMap;
    Integer johnAge = lmap.remove("John");// by object
    assertEquals(johnAge, new Integer(36));
    assertEquals(lmap.size(), RUNNERS_COUNT - 1);

    Integer emilyAge = lmap.remove(0);// by index
    assertEquals(emilyAge, new Integer(37));
    assertEquals(lmap.size(), RUNNERS_COUNT - 2);
}
 
Example #14
Source File: SimpleARC.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
public SimpleARC(int size) {
  this.size = size;
  this.recencySize = 0;
  this.topLRU1 = new LinkedMap<>();
  this.topLRU2 = new LinkedMap<>();
  this.bottomLRU1 = new LinkedMap<>();
  this.bottomLRU2 = new LinkedMap<>();
}
 
Example #15
Source File: CAR.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
public CAR(int size) {
  this.size = size;
  this.recency = new Clock(this.size);
  this.frequency = new Clock(this.size);
  this.recencyGhost = new LinkedMap<>();
  this.frequencyGhost = new LinkedMap<>();
  this.recencyTarget = 0;
}
 
Example #16
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Before
public void createRunners() {
    // First implementation: ListOrderedMap
    this.runnersListOrderedMap = new ListOrderedMap<>();
    this.loadOrderedMapOfRunners(this.runnersListOrderedMap);

    // Second implementation: LinkedMap
    this.runnersLinkedMap = new LinkedMap<>();
    this.loadOrderedMapOfRunners(this.runnersLinkedMap);
}
 
Example #17
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenALinkedMap_whenConvertedToList_thenMatchesKeySet() {
    // Casting the OrderedMap to a LinkedMap we can use asList() method

    LinkedMap<String, Integer> lmap = (LinkedMap<String, Integer>) this.runnersLinkedMap;
    List<String> listKeys = new ArrayList<>();
    listKeys.addAll(this.runnersLinkedMap.keySet());
    List<String> linkedMap = lmap.asList();
    assertEquals(listKeys, linkedMap);
}
 
Example #18
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenALinkedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() {
    LinkedMap<String, Integer> lmap = (LinkedMap<String, Integer>) this.runnersLinkedMap;

    for (int i = 0; i < RUNNERS_COUNT; i++) {
        // accessed by index:
        String name = lmap.get(i);
        assertEquals(name, this.names[i]);

        // index of key concides with position in array
        assertEquals(lmap.indexOf(this.names[i]), i);
    }
}
 
Example #19
Source File: ContainerGroupTableItems.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Nullable
protected GroupInfo<MetaPropertyPath> groupItems(int propertyIndex, @Nullable GroupInfo parent, List<GroupInfo> children,
                                                 E item, LinkedMap<MetaPropertyPath, Object> groupValues) {
    MetaPropertyPath property = (MetaPropertyPath) groupProperties[propertyIndex++];
    Object itemValue = getValueByProperty(item, property);
    groupValues.put(property, itemValue);

    GroupInfo<MetaPropertyPath> groupInfo = new GroupInfo<>(groupValues);
    itemGroups.put(item.getId(), groupInfo);

    if (!parents.containsKey(groupInfo)) {
        parents.put(groupInfo, parent);
    }

    if (!children.contains(groupInfo)) {
        children.add(groupInfo);
    }

    List<GroupInfo> groupChildren =
            this.children.computeIfAbsent(groupInfo, k -> new ArrayList<>());

    if (propertyIndex < groupProperties.length) {
        groupInfo = groupItems(propertyIndex, groupInfo, groupChildren, item, groupValues);
    }

    return groupInfo;
}
 
Example #20
Source File: CollectionDatasourceImpl.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void includeItemFirst(T item) {
    checkNotNullArgument(item, "item is null");
    internalIncludeItem(item, () -> {
        LinkedMap tmpMap = data.clone();
        data.clear();
        data.put(item.getId(), item);
        data.putAll(tmpMap);
    });
}
 
Example #21
Source File: CollectionDatasourceImpl.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void addItemFirst(T item) {
    checkNotNullArgument(item, "item is null");
    internalAddItem(item, () -> {
        LinkedMap tmpMap = data.clone();
        data.clear();
        data.put(item.getId(), item);
        data.putAll(tmpMap);
    });
}
 
Example #22
Source File: Collections4.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
private static void orderedMap(){
    System.out.println("\norderedMap():");

    OrderedMap<Integer, String> map = new LinkedMap<>();
    map.put(4, "four");
    map.put(7, "seven");
    map.put(12, "twelve");
    System.out.println(map.firstKey());     //prints: 4
    System.out.println(map.nextKey(2));  //prints: null
    System.out.println(map.nextKey(7));  //prints: 12
    System.out.println(map.nextKey(4));  //prints: 7
}
 
Example #23
Source File: BirtStatisticsServiceImpl.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getRecipientMonthlyStatisticsUrlWithoutFormat(ComAdmin admin, String sessionId, RecipientProgressStatisticDto monthlyStatistic) throws Exception {
	Map<String, Object> map = new LinkedMap<>();
	map.put(REPORT_NAME, monthlyStatistic.getReportName());
	map.put(COMPANY_ID, admin.getCompanyID());
	map.put(MEDIA_TYPE, monthlyStatistic.getMediaType());
	map.put(IS_SVG, true);

	DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DateUtilities.YYYY_MM_DD);

	int startYear = monthlyStatistic.getStartYear();
	int startMonth = monthlyStatistic.getStartMonth();
	LocalDate startDate = LocalDate.of(startYear, startMonth + 1, 1);

	map.put(RECIPIENT_START_DATE, DateUtilities.format(startDate, dateFormatter));
	map.put(RECIPIENT_STOP_DATE, DateUtilities.format(startDate.with(lastDayOfMonth()), dateFormatter));

	map.put(TARGET_ID, monthlyStatistic.getTargetId());
	map.put(MAILING_LIST_ID, monthlyStatistic.getMailinglistId());
	map.put(HOUR_SCALE, monthlyStatistic.isHourScale());
	map.put(LANGUAGE, admin.getAdminLang());
	map.put(SECURITY_TOKEN, BirtInterceptingFilter.createSecurityToken(configService, admin.getCompanyID()));
	map.put(EMM_SESSION, sessionId);
	map.put(TARGET_BASE_URL.toLowerCase(), generateTargetBaseUrl());

	return generateUrlWithParamsForExternalAccess(map);
}
 
Example #24
Source File: BirtStatisticsServiceImpl.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getMonthlyStatisticsUrlWithoutFormat(ComAdmin admin, String sessionId, MonthlyStatisticDto monthlyStatistic, boolean forInternalUse) throws Exception {
	Map<String, Object> map = new LinkedMap<>();
	map.put(REPORT_NAME, monthlyStatistic.getReportName());
	map.put(COMPANY_ID, admin.getCompanyID());
	map.put(ADMIN_ID, admin.getAdminID());

	DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(DateUtilities.YYYYMMDD);

	int startYear = monthlyStatistic.getStartYear();
	int startMonth = monthlyStatistic.getStartMonth();
	LocalDate startDate = LocalDate.of(startYear, startMonth + 1, 1);

	map.put(START_DATE, DateUtilities.format(startDate, dateFormatter));
	map.put(END_DATE, DateUtilities.format(startDate.with(lastDayOfMonth()), dateFormatter));
	
	map.put(INCLUDE_ADMIN_AND_TEST_MAILS, false);
	map.put(TOP_10_METRICS, monthlyStatistic.getTop10MetricsId());
	map.put(LANGUAGE, admin.getAdminLang());
	map.put(SECURITY_TOKEN, BirtInterceptingFilter.createSecurityToken(configService, admin.getCompanyID()));
	map.put(SESSION_ID, sessionId);
	map.put(EMM_SESSION, sessionId);
	map.put(TARGET_BASE_URL, generateTargetBaseUrl());
	
	if (forInternalUse) {
		return generateUrlWithParamsForInternalAccess(map);
	} else {
		return generateUrlWithParamsForExternalAccess(map);
	}
}
 
Example #25
Source File: Clock.java    From cache2k-benchmark with Apache License 2.0 4 votes vote down vote up
public Clock(int size) {
	this.size = size;
	this.clock = new LinkedMap<Integer, CacheMetaData>();
}
 
Example #26
Source File: SimpleLRU.java    From cache2k-benchmark with Apache License 2.0 4 votes vote down vote up
public SimpleLRU(int size) {
  this.size = size;
  this.lru = new LinkedMap<Integer, CacheMetaData>();
}
 
Example #27
Source File: GroupInfo.java    From cuba with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public GroupInfo(LinkedMap groupingValues) {
    this.groupingValues = new LinkedMap(groupingValues);
    this.groupProperty = (P) groupingValues.get(groupingValues.size() - 1);
}
 
Example #28
Source File: ReadOnlyLinkedMapValuesView.java    From cuba with Apache License 2.0 4 votes vote down vote up
public static Iterator createValuesIterator(LinkedMap linkedMap) {
    return new ReadOnlyValuesIterator(linkedMap);
}
 
Example #29
Source File: ReadOnlyLinkedMapValuesView.java    From cuba with Apache License 2.0 4 votes vote down vote up
public ReadOnlyLinkedMapValuesView(LinkedMap parent) {
    this.parent = parent;
}