Caldav: implement task priority over EWS

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1968 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-06-05 22:29:12 +00:00
parent d6d5e66d01
commit b00d441b68
2 changed files with 37 additions and 0 deletions

View File

@ -1346,6 +1346,7 @@ public class EwsExchangeSession extends ExchangeSession {
EWSMethod.Item newItem = new EWSMethod.Item();
newItem.type = "Task";
List<FieldUpdate> updates = new ArrayList<FieldUpdate>();
updates.add(Field.createFieldUpdate("importance", convertPriorityToExchange(vCalendar.getFirstVeventPropertyValue("PRIORITY"))));
updates.add(Field.createFieldUpdate("calendaruid", vCalendar.getFirstVeventPropertyValue("UID")));
// force urlcompname
updates.add(Field.createFieldUpdate("urlcompname", convertItemNameToEML(itemName)));
@ -1555,6 +1556,7 @@ public class EwsExchangeSession extends ExchangeSession {
GetItemMethod getItemMethod;
if ("Task".equals(type)) {
getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, false);
getItemMethod.addAdditionalProperty(Field.get("importance"));
getItemMethod.addAdditionalProperty(Field.get("subject"));
getItemMethod.addAdditionalProperty(Field.get("created"));
getItemMethod.addAdditionalProperty(Field.get("lastmodified"));
@ -1599,6 +1601,7 @@ public class EwsExchangeSession extends ExchangeSession {
vTodo.setPropertyValue("UID", calendarUid);
vTodo.setPropertyValue("SUMMARY", getItemMethod.getResponseItem().get(Field.get("subject").getResponseName()));
vTodo.setPropertyValue("DESCRIPTION", getItemMethod.getResponseItem().get(Field.get("description").getResponseName()));
vTodo.setPropertyValue("PRIORITY", convertPriorityFromExchange(getItemMethod.getResponseItem().get(Field.get("importance").getResponseName())));
vTodo.setPropertyValue("PERCENT-COMPLETE", getItemMethod.getResponseItem().get(Field.get("percentcomplete").getResponseName()));
vTodo.setPropertyValue("STATUS", taskTovTodoStatusMap.get(getItemMethod.getResponseItem().get(Field.get("taskstatus").getResponseName())));
@ -2366,5 +2369,38 @@ public class EwsExchangeSession extends ExchangeSession {
protected static boolean isItemId(String itemName) {
return itemName.length() >= 152;
}
protected static final Map<String, String> importanceToPriorityMap = new HashMap<String, String>();
static {
importanceToPriorityMap.put("High", "1");
importanceToPriorityMap.put("Normal", "5");
importanceToPriorityMap.put("Low", "9");
}
protected static final Map<String, String> priorityToImportanceMap = new HashMap<String, String>();
static {
priorityToImportanceMap.put("1", "High");
priorityToImportanceMap.put("5", "Normal");
priorityToImportanceMap.put("9", "Low");
}
protected String convertPriorityFromExchange(String exchangeImportanceValue) {
String value = null;
if (exchangeImportanceValue != null) {
value = importanceToPriorityMap.get(exchangeImportanceValue);
}
return value;
}
protected String convertPriorityToExchange(String vTodoPriorityValue) {
String value = null;
if (vTodoPriorityValue != null) {
value = priorityToImportanceMap.get(vTodoPriorityValue);
}
return value;
}
}

View File

@ -218,6 +218,7 @@ public final class Field {
FIELD_MAP.put("xmozsendinvitations", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsendinvitations"));
// task
FIELD_MAP.put("importance", new UnindexedFieldURI("item:Importance"));
FIELD_MAP.put("percentcomplete", new UnindexedFieldURI("task:PercentComplete"));
FIELD_MAP.put("taskstatus", new UnindexedFieldURI("task:Status"));