Class GenericPodioImpl
- java.lang.Object
-
- com.java_podio.code_gen.static_interface.GenericPodioImpl
-
- All Implemented Interfaces:
GenericPodioInterface
public abstract class GenericPodioImpl extends Object implements GenericPodioInterface
Generic interface methods for generatedAppWrapperclasses.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_OFFSETstatic SimpleDateFormatdefaultDateFormatNoTimeThis is not thread safe!
-
Constructor Summary
Constructors Constructor Description GenericPodioImpl()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intaddItem(AppWrapper item)<T extends AppWrapper>
List<T>filterAllItems(Class<T> app, com.podio.item.filter.ItemFilter filter)<T extends AppWrapper>
List<T>filterAllItems(Class<T> app, com.podio.item.filter.ItemFilter filter, boolean fetchCompleteItems)<T extends AppWrapper>
Stream<T>filterAllItemsAppWrapperStream(Class<T> app, com.podio.item.filter.ItemFilter filter, boolean fetchCompleteItems)Stream<com.podio.item.ItemBadge>filterAllItemsStream(int appId, com.podio.item.filter.ItemFilter filter)<T extends AppWrapper>
List<T>getAllItems(Class<T> app)Fetches all entries for an app from Podio.protected abstract <T extends com.podio.BaseAPI>
TgetAPI(Integer appId, Class<T> type)User or app credentials might be used here.<T extends AppWrapper>
List<T>getAssociatedItems(Class<T> type, String fieldId, Integer podioId)This directly queries the given app (typeand field.<T extends AppWrapper>
TgetItemById(Class<T> type, Integer podioId)<T extends AppWrapper>
List<T>getItemsById(Class<T> type, List<Integer> podioIds)TODO: speed up by doing only one remote call!<T extends AppWrapper>
List<T>getItemsById(Class<T> type, List<Integer> podioIds, JProgressBar progressBar)TODO: speed up by doing only one remote call!static <T extends AppWrapper>
TnewAppWrapper(Class<T> type, com.podio.item.Item item)Creates a newAppWrapperinstance of type T with values fromitem.static <T extends AppWrapper>
TnewAppWrapperNoException(Class<T> type, com.podio.item.Item item)<T extends AppWrapper>
TupdateItem(T item)Updates item with all fields.<T extends AppWrapper>
List<T>updateItems(Collection<T> items, JProgressBar progressBar)All items are assumed to be of the same type!<T extends AppWrapper>
List<T>updateItems(List<T> items)All items are assumed to be of the same type!intuploadFile(File file, int appId, String filename)
-
-
-
Field Detail
-
DEFAULT_OFFSET
public static final int DEFAULT_OFFSET
- See Also:
- Constant Field Values
-
defaultDateFormatNoTime
public static SimpleDateFormat defaultDateFormatNoTime
This is not thread safe! If used concurrently this needs to be changed toThreadLocal!
-
-
Method Detail
-
getAPI
protected abstract <T extends com.podio.BaseAPI> T getAPI(Integer appId, Class<T> type)
User or app credentials might be used here.- Parameters:
appId-type- api type- Returns:
-
uploadFile
public int uploadFile(File file, int appId, String filename)
- Specified by:
uploadFilein interfaceGenericPodioInterface- Returns:
- fileId
-
addItem
public int addItem(AppWrapper item)
- Specified by:
addItemin interfaceGenericPodioInterface- Parameters:
item- podioId will be set for this object- Returns:
- podioId of the created item
-
getItemById
public <T extends AppWrapper> T getItemById(Class<T> type, Integer podioId)
- Specified by:
getItemByIdin interfaceGenericPodioInterface
-
getItemsById
public <T extends AppWrapper> List<T> getItemsById(Class<T> type, List<Integer> podioIds)
Description copied from interface:GenericPodioInterfaceTODO: speed up by doing only one remote call!- Specified by:
getItemsByIdin interfaceGenericPodioInterface- Returns:
-
getItemsById
public <T extends AppWrapper> List<T> getItemsById(Class<T> type, List<Integer> podioIds, JProgressBar progressBar)
Description copied from interface:GenericPodioInterfaceTODO: speed up by doing only one remote call!- Specified by:
getItemsByIdin interfaceGenericPodioInterface- Returns:
-
updateItem
public <T extends AppWrapper> T updateItem(T item) throws PodioConflictException
Description copied from interface:GenericPodioInterfaceUpdates item with all fields. AssumesAppWrapper.getPodioId()is set.- Specified by:
updateItemin interfaceGenericPodioInterface- Returns:
- the updated item, this contains the new revision
- Throws:
PodioConflictException
-
updateItems
public <T extends AppWrapper> List<T> updateItems(List<T> items) throws ParseException, PodioConflictException
Description copied from interface:GenericPodioInterfaceAll items are assumed to be of the same type!- Specified by:
updateItemsin interfaceGenericPodioInterface- Returns:
- Throws:
ParseExceptionPodioConflictException- See Also:
GenericPodioInterface.updateItem(AppWrapper)
-
updateItems
public <T extends AppWrapper> List<T> updateItems(Collection<T> items, JProgressBar progressBar) throws ParseException, PodioConflictException
Description copied from interface:GenericPodioInterfaceAll items are assumed to be of the same type!- Specified by:
updateItemsin interfaceGenericPodioInterface- Returns:
- Throws:
ParseExceptionPodioConflictException- See Also:
GenericPodioInterface.updateItem(AppWrapper)
-
filterAllItems
public <T extends AppWrapper> List<T> filterAllItems(Class<T> app, com.podio.item.filter.ItemFilter filter) throws InterruptedException, ExecutionException
- Specified by:
filterAllItemsin interfaceGenericPodioInterface- Throws:
InterruptedExceptionExecutionException
-
filterAllItemsStream
public Stream<com.podio.item.ItemBadge> filterAllItemsStream(int appId, com.podio.item.filter.ItemFilter filter)
- Specified by:
filterAllItemsStreamin interfaceGenericPodioInterface
-
filterAllItemsAppWrapperStream
public <T extends AppWrapper> Stream<T> filterAllItemsAppWrapperStream(Class<T> app, com.podio.item.filter.ItemFilter filter, boolean fetchCompleteItems)
- Specified by:
filterAllItemsAppWrapperStreamin interfaceGenericPodioInterface
-
filterAllItems
public <T extends AppWrapper> List<T> filterAllItems(Class<T> app, com.podio.item.filter.ItemFilter filter, boolean fetchCompleteItems)
- Specified by:
filterAllItemsin interfaceGenericPodioInterface- Type Parameters:
T-- Parameters:
app-filter- attributes 'offset' and 'limit' are assumed not to be set (this method fetches _all_ filtered items!)fetchCompleteItems-- Returns:
- Throws:
InterruptedExceptionExecutionException
-
getAllItems
public <T extends AppWrapper> List<T> getAllItems(Class<T> app) throws InterruptedException, ExecutionException
Description copied from interface:GenericPodioInterfaceFetches all entries for an app from Podio. This is done parallel in chunks of 500 (which is the maximum). Note: this uses some undocumented URI ( ItemAPI#getItems() ) - the resulting items are missing e.g. the files attribute.- Specified by:
getAllItemsin interfaceGenericPodioInterface- Parameters:
app- generated class of app- Returns:
- Throws:
InterruptedExceptionExecutionException
-
getAssociatedItems
public <T extends AppWrapper> List<T> getAssociatedItems(Class<T> type, String fieldId, Integer podioId) throws PodioApiWrapperException
Description copied from interface:GenericPodioInterfaceThis directly queries the given app (typeand field. For all references employItemAPI.getItemReference(int)(which will probably be slower, as it needs 2 remote calls).- Specified by:
getAssociatedItemsin interfaceGenericPodioInterface- Parameters:
type- app of items that are returnedfieldId- id of referencing field in apptype. Can be field id or field external id.podioId- referenced item (might not be in apptype!)- Returns:
- list of items from app
typethat referencepodioIdin fieldfieldId - Throws:
PodioApiWrapperException
-
newAppWrapper
public static <T extends AppWrapper> T newAppWrapper(Class<T> type, com.podio.item.Item item) throws PodioApiWrapperException
Creates a newAppWrapperinstance of type T with values fromitem.- Parameters:
type-item- might benull- this results in the default constructor.- Returns:
- Throws:
PodioApiWrapperException
-
newAppWrapperNoException
public static <T extends AppWrapper> T newAppWrapperNoException(Class<T> type, com.podio.item.Item item)
-
-