Java Code Examples for org.apache.commons.collections4.map.CaseInsensitiveMap#remove()

The following examples show how to use org.apache.commons.collections4.map.CaseInsensitiveMap#remove() . 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: RecipientAction.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the list of recipient fields
 *
 * @param companyId
 *            current company ID
 * @return recipient fields in a form of map: column -> column-shortname
 * @throws Exception
 *             if the exception happens in columnInfoService class
 */
protected Map<String, String> getRecipientFieldsNames(int companyId, int adminId) throws Exception {
	final CaseInsensitiveMap<String, ProfileField> columnInfoMap = columnInfoService.getColumnInfoMap(companyId, adminId);
	final LinkedHashMap<String, String> fieldsMap = new LinkedHashMap<>();
	
	// we need predefined order for default columns: gender, firstname, lastname.
	fieldsMap.put(COLUMN_GENDER, columnInfoMap.get(COLUMN_GENDER).getShortname());
	fieldsMap.put(COLUMN_FIRSTNAME, columnInfoMap.get(COLUMN_FIRSTNAME).getShortname());
	fieldsMap.put(COLUMN_LASTNAME, columnInfoMap.get(COLUMN_LASTNAME).getShortname());
	
	columnInfoMap.remove(COLUMN_GENDER);
	columnInfoMap.remove(COLUMN_FIRSTNAME);
	columnInfoMap.remove(COLUMN_LASTNAME);

	columnInfoMap.forEach((key, value) -> fieldsMap.put(key, value.getShortname()));
	
	MapUtils.reorderLinkedHashMap(fieldsMap, RecipientUtils.getFieldOrderComparator());

	return fieldsMap;
}
 
Example 2
Source File: RecipientUtils.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Map<String, String> sortDuplicateAnalysisFields(CaseInsensitiveMap<String, ProfileField> columnMap) {
final LinkedHashMap<String, String> fieldsMap = new LinkedHashMap<>();

// we need predefined order for default columns: gender, firstname, lastname.
fieldsMap.put(COLUMN_GENDER, columnMap.get(COLUMN_GENDER).getShortname());
fieldsMap.put(COLUMN_FIRSTNAME, columnMap.get(COLUMN_FIRSTNAME).getShortname());
fieldsMap.put(COLUMN_LASTNAME, columnMap.get(COLUMN_LASTNAME).getShortname());
fieldsMap.put(COLUMN_TIMESTAMP, columnMap.get(COLUMN_TIMESTAMP).getShortname());
fieldsMap.put(COLUMN_CUSTOMER_ID, columnMap.get(COLUMN_CUSTOMER_ID).getShortname());

columnMap.remove(COLUMN_GENDER);
columnMap.remove(COLUMN_FIRSTNAME);
columnMap.remove(COLUMN_LASTNAME);
columnMap.remove(COLUMN_TIMESTAMP);
columnMap.remove(COLUMN_CUSTOMER_ID);

columnMap.forEach((key, value) -> fieldsMap.put(key, value.getShortname()));

MapUtils.reorderLinkedHashMap(fieldsMap, RecipientUtils.getFieldOrderComparator(true));

return fieldsMap;
  }