public class ProductService extends Object
User: Kirill, Date: 05.08.13 18:00
.Modifier and Type | Field and Description |
---|---|
private Credentials |
credentials |
private Transport |
transport |
private URL |
url |
Constructor and Description |
---|
ProductService(URL url,
Credentials credentials,
Transport transport)
Constructs the service.
|
Modifier and Type | Method and Description |
---|---|
IdentifierInfo |
create(int version,
ProductInfo productInfo)
Create product on the server.
|
void |
delete(int version,
String identifier)
Delete entity from the server.
|
void |
deletePicture(int version,
String productIdentifier,
String pictureFilename)
Deletes specified picture.
|
private String |
formatPictureUrl(String productIdentifier,
String pictureFilename,
Integer version) |
ProductInfo |
get(Integer version,
String identifier)
Returns an entity.
|
InputStream |
getPicture(Integer version,
String productIdentifier,
String pictureFilename)
Returns body of the picture.
|
InputStream |
getPictureFromHistory(Integer pictureVersion,
String productIdentifier,
String pictureFilename)
Returns body of the picture for particular version number.
|
List<String> |
getPicturePath(Integer version,
String productIdentifier)
Returns list of picture relative paths .
|
List<ProductInfo> |
list(Integer version)
Returns list of entities.
|
List<ProductInfo> |
list(Integer version,
Integer firstResult,
Integer maxResults,
String like,
ProductInfo.Fields orderBy,
Boolean orderDesc)
Returns list of entities.
|
List<ProductAdvancedInfo> |
listAdvanced(Integer version,
Integer firstResult,
Integer maxResults,
String like,
ProductInfo.Fields orderBy,
Boolean orderDesc)
Returns list of advanced entities.
|
List<ProductInfo> |
listDiff(int versionFrom,
int versionTo)
Returns list of item changes between two versions.
|
List<ProductPictureInfo> |
listDiffPicture(int versionFrom,
int versionTo)
Returns list of product pictures changes between two versions.
|
void |
put(int version,
ProductInfo productInfo)
Put product to the server.
|
void |
putPicture(int version,
String productIdentifier,
String pictureFilename,
InputStream picture,
String contentType)
Send picture to the server.
|
ProductsStatsInfo |
stats(String period,
String cashRegisterName)
Returns stats by products.
|
private URL url
private Credentials credentials
private Transport transport
public ProductService(URL url, Credentials credentials, Transport transport)
url
- of the servercredentials
- to work with the servertransport
- to know the method to reach the serverpublic ProductInfo get(Integer version, String identifier)
version
- latest version of seller, may be null (if latest data needed)identifier
- identifies entity. must match to Constraints.WINDOWS_FILENAME_REGEX
VersionConflictJsonException
- if version mismatchNotFoundJsonException
- if entity is not foundpublic void put(int version, ProductInfo productInfo)
version
- expected latest version of sellerproductInfo
- data to putVersionConflictJsonException
- if version mismatchReferenceNotFoundJsonException
- if tax in ProductInfo.tax
is not foundpublic IdentifierInfo create(int version, ProductInfo productInfo)
version
- expected latest version of sellerproductInfo
- data to putVersionConflictJsonException
- if version mismatchReferenceNotFoundJsonException
- if tax in ProductInfo.tax
is not foundpublic void delete(int version, String identifier)
version
- current seller versionidentifier
- identifies entity. must match to Constraints.WINDOWS_FILENAME_REGEX
VersionConflictJsonException
- if version mismatchpublic List<ProductInfo> listDiff(int versionFrom, int versionTo)
versionFrom
- version from includedversionTo
- version to includedProductInfo.deleted
= true)public List<ProductInfo> list(Integer version)
version
- version or null if fresh data requiredpublic List<ProductInfo> list(Integer version, Integer firstResult, Integer maxResults, String like, ProductInfo.Fields orderBy, Boolean orderDesc)
firstResult
- when pagination starts or nullmaxResults
- amount of items per page or nulllike
- search string filter or nullorderBy
- field to order by, possible values are "IDENTIFIER", "NAME", "BARCODE", "NETTO", "TAX_NAME", "SALES_UNIT", "COUNTED_IN_PRICE"orderDesc
- field to direction of orderingversion
- version or null if fresh data requiredpublic List<ProductAdvancedInfo> listAdvanced(Integer version, Integer firstResult, Integer maxResults, String like, ProductInfo.Fields orderBy, Boolean orderDesc)
firstResult
- when pagination starts or nullmaxResults
- amount of items per page or nulllike
- search string filter or nullorderBy
- field to order by, possible values are "IDENTIFIER", "NAME", "BARCODE", "NETTO", "TAX_NAME", "SALES_UNIT", "COUNTED_IN_PRICE"orderDesc
- field to direction of orderingversion
- version or null if fresh data requiredpublic List<ProductPictureInfo> listDiffPicture(int versionFrom, int versionTo)
versionFrom
- version from includedversionTo
- version to includedProductServiceSample
public InputStream getPicture(Integer version, String productIdentifier, String pictureFilename)
version
- picture version or null if fresh content neededproductIdentifier
- product identifierpictureFilename
- just a normal windows filename according to Constraints.WINDOWS_FILENAME_REGEX
NotFoundJsonException
- if image is not foundReferenceNotFoundJsonException
- if product is not foundProductServiceSample
public List<String> getPicturePath(Integer version, String productIdentifier)
version
- picture version or null if fresh content neededproductIdentifier
- product identifierReferenceNotFoundJsonException
- if seller is not foundProductServiceSample
public InputStream getPictureFromHistory(Integer pictureVersion, String productIdentifier, String pictureFilename)
pictureVersion
- particular version of pictureproductIdentifier
- product identifierpictureFilename
- just a normal windows filename according to Constraints.WINDOWS_FILENAME_REGEX
NotFoundJsonException
- if image is not foundReferenceNotFoundJsonException
- if product is not foundProductServiceSample
public void putPicture(int version, String productIdentifier, String pictureFilename, InputStream picture, String contentType)
version
- expected latest version of sellerproductIdentifier
- identifier of the product. must match to Constraints.WINDOWS_FILENAME_REGEX
pictureFilename
- picture filename. must match to Constraints.WINDOWS_FILENAME_REGEX
picture
- body of the picture. method doesn't close the streamcontentType
- content type of the imageReferenceNotFoundJsonException
- if product is not foundVersionConflictJsonException
- if version doesn't match to seller versionProductServiceSample
private String formatPictureUrl(String productIdentifier, String pictureFilename, Integer version)
public void deletePicture(int version, String productIdentifier, String pictureFilename)
version
- version of seller, if mismatch VersionConflictJsonException
will be thrownproductIdentifier
- identifier of the product. must match to Constraints.WINDOWS_FILENAME_REGEX
pictureFilename
- picture filename. must match to Constraints.WINDOWS_FILENAME_REGEX
ReferenceNotFoundJsonException
- if product is not foundVersionConflictJsonException
- if version doesn't match to seller versionProductServiceSample
public ProductsStatsInfo stats(String period, String cashRegisterName)
period
- filters by date periodcashRegisterName
- filters by cash register nameProductsStatsInfo
with stats.TypeMismatchJsonException
- if period
String
isn't convertible to
Date
.Copyright © 2016. All rights reserved.