added updateListItems support
This commit is contained in:
@ -0,0 +1,33 @@
|
|||||||
|
package de.muehlencord.shared.sharepoint.api;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author joern.muehlencord
|
||||||
|
*/
|
||||||
|
public class SPHelper {
|
||||||
|
|
||||||
|
private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||||
|
private static final SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
/* -- Format for Date Only Field -- */
|
||||||
|
public static String toSPDate(Date d) {
|
||||||
|
if (d == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return dateOnlyFormat.format(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -- Format for DateTime Field -- */
|
||||||
|
private static String toSPDateAndTime(Date d) {
|
||||||
|
if (d == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateTimeFormat.format(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -10,15 +10,11 @@ import javax.xml.bind.JAXBContext;
|
|||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -160,6 +160,19 @@ public class SPList extends SPJaxbObject<List> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateListItem(Map<String, String> data) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
|
||||||
|
SAXException, KeyManagementException, IOException {
|
||||||
|
java.util.List<Map<String, String>> dataList = new ArrayList<>();
|
||||||
|
dataList.add(data);
|
||||||
|
updateListItems(dataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateListItems(java.util.List<Map<String, String>> dataList) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
|
||||||
|
SAXException, KeyManagementException, IOException {
|
||||||
|
SPBatch batch = createBatch(dataList, MethodType.UPDATE);
|
||||||
|
executeUpdate(batch);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeListItem(Map<String, String> dataMap) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
|
public void removeListItem(Map<String, String> dataMap) throws JAXBException, ParserConfigurationException, NoSuchAlgorithmException,
|
||||||
SAXException, KeyManagementException, IOException {
|
SAXException, KeyManagementException, IOException {
|
||||||
java.util.List<Map<String, String>> dataList = new ArrayList<>();
|
java.util.List<Map<String, String>> dataList = new ArrayList<>();
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class SPLists extends SPJaxbObject<de.muehlencord.shared.sharepoint.api.l
|
|||||||
if (this.getValue().lists == null) {
|
if (this.getValue().lists == null) {
|
||||||
getValueFromSharepoint();
|
getValueFromSharepoint();
|
||||||
}
|
}
|
||||||
List list = getListByTitle(listName);
|
List list = getListByTitle(listName); // TODO throw exception if not found
|
||||||
SPList returnList = new SPList(getContext(), listName);
|
SPList returnList = new SPList(getContext(), listName);
|
||||||
returnList.setValue(list);
|
returnList.setValue(list);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user