public abstract class Attachment
extends java.lang.Object
implements java.io.Serializable, com.labvantage.sapphire.gwt.shared.JSONable
| Modifier and Type | Class and Description |
|---|---|
static class |
Attachment.AttachmentType
Attachment Type Enumeration
Type File now includes all backwards compatiable types such as Store, Reference, Upload and Store and Upload and Reference
|
static class |
Attachment.ThumbnailGeneration
Thummail Generation Enumeration
Used to determine how the system handles and generates Thumbnails
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TYPE_FORMATTEDTEXT |
static java.lang.String |
TYPE_LINKEDREFERENCE |
static java.lang.String |
TYPE_PLAINTEXT |
static java.lang.String |
TYPE_REFERENCE |
static java.lang.String |
TYPE_STORE |
static java.lang.String |
TYPE_UPLOADANDREFERENCE |
static java.lang.String |
TYPE_UPLOADANDSTORE |
static java.lang.String |
TYPE_URL |
| Constructor and Description |
|---|
Attachment() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkHash(long hash) |
protected boolean |
checkHash(java.lang.String databaseId) |
static java.lang.String |
evaluateFileNameExpressions(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum,
ConnectionInfo connectionInfo,
java.lang.String input,
Attachment attachment) |
static java.lang.String |
evaluateFileNameExpressions(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum,
int auditsequence,
ConnectionInfo connectionInfo,
java.lang.String input,
Attachment attachment) |
void |
generateThumbnail(java.lang.String connectionid)
Will generate the thumbnail and populate the Thumbnail property of the attachment object.
|
java.lang.String |
getAdditionalColumn(java.lang.String key,
java.lang.String defaultValue)
Will return the value of the column provided.
|
protected PropertyList |
getAdditionalColumns() |
protected boolean |
getAllowLocalCache() |
static Attachment |
getAttachment(DataSet sdiAttachmentData,
int sdiAttRow,
java.lang.String connectionId)
Used to fetch a new Attachment object based off a data set of sdiattachment records.
|
static Attachment |
getAttachment(DataSet sdiAttachmentData,
java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentNum,
java.lang.String connectionId)
Get an attachment object based off attachment data
|
static Attachment |
getAttachment(PropertyList propertyList,
java.lang.String connectionId)
Used to fetch a new Attachment object based off a property list provided.
|
static Attachment |
getAttachment(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3)
Used to fetch a new black attachment object which can then be fed into the Attachment Processor.
|
static Attachment |
getAttachment(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum)
Used to fetch a new black attachment object which can then be fed into the Attachment Processor.
|
static Attachment |
getAttachment(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentNum,
QueryProcessor queryProcessor,
java.lang.String connectionId)
Get an attachment object based on sdcid,keyid1, 2 and 3
|
java.lang.String |
getAttachmentClass()
Returns the attachment class
|
int |
getAttachmentNum()
Returns the attachment number
|
protected BaseAttachmentRepository |
getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection,
PropertyList attachmentPolicy)
Will return the Attachment Repository object based of the Attachment object.
|
protected BaseAttachmentRepository |
getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection,
PropertyList attachmentPolicy,
boolean defaultToCompatability)
Will return the Attachment Repository object based of the Attachment object.
|
protected BaseAttachmentRepository |
getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection,
PropertyList attachmentPolicy,
boolean defaultToCompatability,
Attachment basedOn)
Will return the Attachment Repository object based of the Attachment object.
|
protected java.lang.String |
getAttachmentRepositoryId() |
protected java.lang.String |
getAttachmentRepositoryNodeId() |
protected com.labvantage.sapphire.attachment.AttachmentRule |
getAttachmentRule() |
Attachment.AttachmentType |
getAttachmentType()
Will return the attachment type of the attachment
|
java.sql.Blob |
getBlob()
Returns the blob value.
|
protected java.nio.file.Path |
getCachedPath(java.lang.String databaseid,
boolean explodedzip) |
java.lang.String |
getClob()
Used to get the clob column on the attachment.
|
byte[] |
getData()
Gets the data in the attachment as a byte array.
|
byte[] |
getData(int maxsizelimit)
Gets the data in the attachment as a byte array.
|
protected long |
getDataHash() |
java.lang.String |
getDescription()
Returns the attachment description
|
java.lang.String |
getFilename()
Returns the file name of the attachment.
|
java.io.InputStream |
getInputStream()
Gets the input stream for adding/updating an attachment
We recommend using this over getting the byte array or blob of the attachment for efficiency and memory management
|
java.lang.String |
getKeyId1()
Get the key id 1
|
java.lang.String |
getKeyId2()
Get the key id 2
|
java.lang.String |
getKeyId3()
Get the key id 3
|
int |
getLinkAttachmentNum()
Gets the Link Attachment Number if the attachment is a linked attachment created from a copy down.
|
java.lang.String |
getLinkKeyId1()
Gets the Link Key Id 1 if the attachment is a linked attachment created from a copy down.
|
java.lang.String |
getLinkKeyId2()
Gets the Link Key Id 2 if the attachment is a linked attachment created from a copy down.
|
java.lang.String |
getLinkKeyId3()
Gets the Link Key Id 3 if the attachment is a linked attachment created from a copy down.
|
java.lang.String |
getLinkSdcid()
Gets the Link SDC Id if the attachment is a linked attachment created from a copy down.
|
protected java.nio.file.Path |
getLocalFile() |
boolean |
getLockAttachment()
Returns true if the attachment is locked from update as part of version control.
|
java.lang.String |
getOleClass()
Gets the OLE class.
|
protected java.lang.String |
getParentDepartment() |
java.lang.String |
getRepositoryId()
Get the external id for the external repository.
|
java.lang.String |
getSDCId()
Get the SDC Id
|
protected java.lang.String |
getSDIAttachmentId() |
long |
getSize()
Gets the size of the data in the attachment
|
java.lang.String |
getSourceFilename()
Returns the source filename of the attachment.
|
java.lang.String |
getTempId()
Returns the Temporary Id for the SDI Temp record
Note this is used internally when uploading an attachment prior to save on a maintenance page.
|
java.lang.String |
getThumbnailImage()
Gets the thumnail image of the attachment.
|
protected boolean |
getTriggerBusinessRule() |
java.lang.String |
getType()
Get the attachment type flag.
|
java.lang.String |
getUploadTo() |
java.lang.String |
getUrl()
Returns the URL if a URL attachment.
|
boolean |
hasData()
Returns true if the attachment has data in it and that data is available to read.
|
boolean |
isByReference()
Will return true to indicate that the file name in this attachment is a reference attachment.
|
boolean |
isCompressed()
Returns true if the attachment was compressed in storage.
|
boolean |
isEncrypted()
Returns true if the attachment was encrypted in storage.
|
protected boolean |
isEncryptionRequired(PropertyList attachmentPolicy,
ConfigurationProcessor cp)
Will return back if encryption is requied based on the attachment rules
|
boolean |
isHashed()
Returns true if the data inside the attachment has been hashed
Internally this returns trus if the datahash of the attachment is not 0.
|
boolean |
isInvalidHash()
Returns true if hashing failed and the attachment has an invalid has.
|
protected boolean |
isZippingRequired(PropertyList attachmentPolicy,
ConfigurationProcessor cp)
Will return back if Zipping is requied based on the attachment rules
|
protected void |
loadLocalFile(java.nio.file.Path p) |
static java.lang.String |
replaceDateTokens(java.lang.String filename) |
static java.lang.String |
replaceDbTokens(java.lang.String filename,
java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
Attachment attachment,
ConnectionInfo connectionInfo) |
static java.lang.String |
replaceInvalidChars(java.lang.String tokens,
java.lang.String replacement) |
protected java.nio.file.Path |
saveLocalFile(boolean cache,
java.lang.String databaseid,
boolean checkHash,
boolean generateHash,
java.nio.file.Path usepath,
boolean doDeleteTempFile) |
protected void |
setAdditionalColumn(java.lang.String key,
java.lang.String value) |
void |
setAdditionalColumns(DataSet sdiAttachmentData,
int sdiAttRow)
Will set any additional columns found in the provided dataset against this attachment object.
|
void |
setAdditionalColumns(PropertyList additionalColumns,
java.lang.String connectionid)
Will set any additional columns found in the provided property list against this attachment object.
|
protected void |
setAllowLocalCache(boolean allowlocalcache) |
void |
setAttachment(DataSet sdiAttachmentData,
int sdiAttRow)
Used to set an attachment object based off a data set of sdiattachment records.
|
void |
setAttachmentClass(java.lang.String attclass)
Set the attachment class for the attachment.
|
protected void |
setAttachmentNum(int attnum) |
protected void |
setAttachmentRepositoryId(java.lang.String attachmentRepositoryId) |
protected void |
setAttachmentRepositoryNodeId(java.lang.String attachmentRepositoryNodeId) |
void |
setAttachmentType(Attachment.AttachmentType attachmentType)
Used to set the type of attachment.
|
void |
setBlob(java.sql.Blob blob)
Sets the blob object on the attachment.
|
void |
setByReference(boolean byReference)
Use this will a parameter value of true to indicate that the file name in this attachment is a reference attachment.
|
void |
setClob(java.lang.String clob)
Used to set the clob column on the attachment.
|
void |
setCompressed(boolean compressedFlag)
Set to true if you wish to force compression.
|
void |
setData(byte[] data)
Sets the file data for the attachment.
|
void |
setDescription(java.lang.String description)
Sets the description of the attachment.
|
void |
setEncrypted(boolean encryptedFlag)
Set to true to encrypt the attachment and force this over the rules evaluation.
|
void |
setFilename(java.lang.String filename)
Sets the filename of the attachment.
|
void |
setInputStream(java.io.InputStream in)
Sets the input stream for adding/updating a new attachment
We recommend using this over setting the byte array or blob of the attachment for efficiency and memory management
|
protected void |
setInvalidHash(boolean invalidHash) |
protected void |
setKeyId1(java.lang.String keyid1) |
protected void |
setKeyId2(java.lang.String keyid2) |
protected void |
setKeyId3(java.lang.String keyid3) |
protected void |
setLinkSDI(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum) |
void |
setLockAttachment(boolean lockAttachment)
Set to true to lock the attachment for update from others and to allow version control.
|
void |
setOleClass(java.lang.String oleClass)
Sets the OLE class.
|
protected void |
setParentDepartment(java.lang.String parentDepartment) |
void |
setRepositoryId(java.lang.String repositoryId)
Set the external id for the external repository.
|
protected void |
setSDCId(java.lang.String sdcid) |
protected void |
setSDIAttachmentId(java.lang.String sdiattachmentid) |
void |
setSize(long size) |
void |
setSourceFilename(java.lang.String sourcefilename)
Sets the source filename of the attachment.
|
void |
setTempId(java.lang.String tempid)
Sets the temporary id for the sdi temp record.
|
void |
setThumbnailImage(java.lang.String thumbnailimage)
Sets the thumnail image of the attachment.
|
protected void |
setTriggerBusinessRule(boolean triggerBusinessRule) |
protected void |
setType(java.lang.String type) |
void |
setUploadTo(java.lang.String uploadTo) |
protected void |
setUrl(java.lang.String url) |
java.lang.String |
toJSONString()
This returns a JSON representation of the attachment object.
|
PropertyList |
toPropertyList(boolean returnData,
boolean thumbnail,
boolean additionalColumns,
java.lang.String connectionid)
Will convert the Attachment object to a property list version where all variables become root properties and
additional columns also become root properties.
|
void |
toPropertyList(PropertyList properties,
boolean returnData,
boolean thumbnail,
boolean returnAdditionalColumns,
java.lang.String connectionid)
Will convert the Attachment object to a property list version where all variables become root properties and
additional columns also become root properties.
|
java.lang.String |
toString() |
public static final java.lang.String TYPE_UPLOADANDSTORE
public static final java.lang.String TYPE_STORE
public static final java.lang.String TYPE_REFERENCE
public static final java.lang.String TYPE_UPLOADANDREFERENCE
public static final java.lang.String TYPE_URL
public static final java.lang.String TYPE_PLAINTEXT
public static final java.lang.String TYPE_LINKEDREFERENCE
public static final java.lang.String TYPE_FORMATTEDTEXT
public static Attachment getAttachment(DataSet sdiAttachmentData, java.lang.String sdcid, java.lang.String keyid1, java.lang.String keyid2, java.lang.String keyid3, int attachmentNum, java.lang.String connectionId)
sdiAttachmentData - sdiattachment datasetsdcid - keyid1 - keyid2 - keyid3 - attachmentNum - connectionId - public static Attachment getAttachment(java.lang.String sdcid, java.lang.String keyid1, java.lang.String keyid2, java.lang.String keyid3, int attachmentNum, QueryProcessor queryProcessor, java.lang.String connectionId)
sdcid - keyid1 - keyid2 - keyid3 - attachmentNum - queryProcessor - connectionId - protected boolean getTriggerBusinessRule()
protected void setParentDepartment(java.lang.String parentDepartment)
protected java.lang.String getParentDepartment()
protected void setTriggerBusinessRule(boolean triggerBusinessRule)
protected java.lang.String getSDIAttachmentId()
protected void setSDIAttachmentId(java.lang.String sdiattachmentid)
protected java.nio.file.Path getLocalFile()
protected java.nio.file.Path getCachedPath(java.lang.String databaseid,
boolean explodedzip)
protected void loadLocalFile(java.nio.file.Path p)
public void setAdditionalColumns(PropertyList additionalColumns, java.lang.String connectionid)
additionalColumns - Key value pair of columns and valuesconnectionid - Current connection id used for file type managementpublic void setAdditionalColumns(DataSet sdiAttachmentData, int sdiAttRow)
sdiAttachmentData - - the sdiattachment table structure for the columns.sdiAttRow - - the row to obtain values from in the sdiattachment dataprotected com.labvantage.sapphire.attachment.AttachmentRule getAttachmentRule()
protected void setAdditionalColumn(java.lang.String key,
java.lang.String value)
protected PropertyList getAdditionalColumns()
protected void setSDCId(java.lang.String sdcid)
protected void setKeyId1(java.lang.String keyid1)
protected void setKeyId2(java.lang.String keyid2)
protected void setKeyId3(java.lang.String keyid3)
protected void setAttachmentNum(int attnum)
protected void setAttachmentRepositoryId(java.lang.String attachmentRepositoryId)
protected void setAttachmentRepositoryNodeId(java.lang.String attachmentRepositoryNodeId)
protected java.lang.String getAttachmentRepositoryId()
protected java.lang.String getAttachmentRepositoryNodeId()
protected void setType(java.lang.String type)
public void setUploadTo(java.lang.String uploadTo)
public java.lang.String getUploadTo()
public void setSize(long size)
protected void setLinkSDI(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum)
protected long getDataHash()
protected boolean checkHash(long hash)
protected void setInvalidHash(boolean invalidHash)
protected java.nio.file.Path saveLocalFile(boolean cache,
java.lang.String databaseid,
boolean checkHash,
boolean generateHash,
java.nio.file.Path usepath,
boolean doDeleteTempFile)
protected boolean checkHash(java.lang.String databaseId)
protected void setUrl(java.lang.String url)
protected boolean getAllowLocalCache()
protected void setAllowLocalCache(boolean allowlocalcache)
protected BaseAttachmentRepository getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection, PropertyList attachmentPolicy, boolean defaultToCompatability) throws SapphireException
sapphireConnection - The SapphireConnection objectattachmentPolicy - The attachment policy property listdefaultToCompatability - Set to true to allow the rules to default to backwards compatible repositories if no repository could be identified.SapphireExceptionprotected BaseAttachmentRepository getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection, PropertyList attachmentPolicy, boolean defaultToCompatability, Attachment basedOn) throws SapphireException
sapphireConnection - The SapphireConnection objectattachmentPolicy - The attachment policy property listdefaultToCompatability - Set to true to allow the rules to default to backwards compatible repositories if no repository could be identified.basedOn - Pass in another Attachment object to base the rule generation on.SapphireExceptionprotected boolean isZippingRequired(PropertyList attachmentPolicy, ConfigurationProcessor cp)
attachmentPolicy - The Attachment policy property listprotected boolean isEncryptionRequired(PropertyList attachmentPolicy, ConfigurationProcessor cp)
attachmentPolicy - The Attachment policy property listprotected BaseAttachmentRepository getAttachmentRepository(com.labvantage.sapphire.services.SapphireConnection sapphireConnection, PropertyList attachmentPolicy) throws SapphireException
sapphireConnection - The SapphireConnection objectattachmentPolicy - The attachment policy property listSapphireExceptionpublic PropertyList toPropertyList(boolean returnData, boolean thumbnail, boolean additionalColumns, java.lang.String connectionid) throws SapphireException
returnData - Set to true to return the data of the attachment. If a file then this is the base64 encoded file datathumbnail - Set to true to return the thumbnail dataadditionalColumns - Set to true to include additional columns (from collection) as root level propertiesSapphireExceptionpublic java.lang.String toJSONString()
toJSONString in interface com.labvantage.sapphire.gwt.shared.JSONablepublic void toPropertyList(PropertyList properties, boolean returnData, boolean thumbnail, boolean returnAdditionalColumns, java.lang.String connectionid) throws SapphireException
properties - The property list to add the properties into.returnData - Set to true to return the data of the attachment. If a file then this is the base64 encoded file datathumbnail - Set to true to return the thumbnail datareturnAdditionalColumns - Set to true to include additional columns (from collection) as root level propertiesSapphireExceptionpublic static Attachment getAttachment(java.lang.String sdcid, java.lang.String keyid1, java.lang.String keyid2, java.lang.String keyid3)
sdcid - SDC Id for the attachment recordkeyid1 - Key Id 1 for the attachment recordkeyid2 - Key Id 2 for the attachment recordkeyid3 - Key Id 3 for the attachment recordpublic static Attachment getAttachment(PropertyList propertyList, java.lang.String connectionId)
propertyList - The property list representing the attachment record.public static Attachment getAttachment(java.lang.String sdcid, java.lang.String keyid1, java.lang.String keyid2, java.lang.String keyid3, int attachmentnum)
sdcid - SDC Id for the attachment recordkeyid1 - Key Id 1 for the attachment recordkeyid2 - Key Id 2 for the attachment recordkeyid3 - Key Id 3 for the attachment recordattachmentnum - The attachment number for the attachment record.public static Attachment getAttachment(DataSet sdiAttachmentData, int sdiAttRow, java.lang.String connectionId)
sdiAttachmentData - The dataset representing the attachment records.sdiAttRow - The row to take from the provided datasetpublic void setAttachment(DataSet sdiAttachmentData, int sdiAttRow)
sdiAttachmentData - The dataset representing the attachment records.sdiAttRow - The row to take from the provided datasetpublic void setByReference(boolean byReference)
byReference - Boolean of true or false for weather the attachment is by referencepublic boolean isByReference()
byReference - Boolean of true or false for weather the attachment is by referencepublic void setAttachmentType(Attachment.AttachmentType attachmentType)
attachmentType - The type of attachment based off of the enumerationpublic Attachment.AttachmentType getAttachmentType()
public java.lang.String getAdditionalColumn(java.lang.String key,
java.lang.String defaultValue)
key - The column id or key of the additional column. An additional column is one which is not core to the sdiattachment table such as a user added column.defaultValue - The default value to return if the column does not exist, the additional columns is empty or the value is null.public java.lang.String getSDCId()
public java.lang.String getKeyId1()
public java.lang.String getKeyId2()
public java.lang.String getKeyId3()
public int getAttachmentNum()
public java.lang.String getAttachmentClass()
public java.lang.String getTempId()
public void setTempId(java.lang.String tempid)
tempid - The temporary id for the sdi temp recordpublic void setRepositoryId(java.lang.String repositoryId)
repositoryId - The external repository id.public java.lang.String getRepositoryId()
repositoryId - The external repository id.public void setAttachmentClass(java.lang.String attclass)
attclass - The attachment classpublic java.lang.String getType()
public java.lang.String getSourceFilename()
public void setSourceFilename(java.lang.String sourcefilename)
sourcefilename - The source filename.public java.lang.String getOleClass()
public void setOleClass(java.lang.String oleClass)
oleClass - The OLE Classpublic void setFilename(java.lang.String filename)
filename - The filename of the attachment.public void setDescription(java.lang.String description)
description - The descriptionpublic void setData(byte[] data)
data - The data for the file in a byte array.public java.lang.String getFilename()
public java.sql.Blob getBlob()
public void setBlob(java.sql.Blob blob)
blob - The blob objectpublic java.lang.String getDescription()
public void setInputStream(java.io.InputStream in)
in - The input stream for the attachment.public java.io.InputStream getInputStream()
public long getSize()
public byte[] getData(int maxsizelimit)
maxsizelimit - The maximum size of the data to return.public boolean hasData()
public byte[] getData()
public void setClob(java.lang.String clob)
clob - The string data for the clob columnpublic java.lang.String getClob()
public void setThumbnailImage(java.lang.String thumbnailimage)
thumbnailimage - The Base64 encoded thumbnail imagepublic java.lang.String getThumbnailImage()
public java.lang.String getLinkSdcid()
public java.lang.String getLinkKeyId1()
public java.lang.String getLinkKeyId2()
public java.lang.String getLinkKeyId3()
public int getLinkAttachmentNum()
public boolean isHashed()
public boolean isInvalidHash()
public boolean isCompressed()
public void setCompressed(boolean compressedFlag)
compressedFlag - Set to true to force compression.public boolean isEncrypted()
public void setEncrypted(boolean encryptedFlag)
encryptedFlag - Set to true to force encryption of the attachmentpublic java.lang.String getUrl()
public void generateThumbnail(java.lang.String connectionid)
throws SapphireException
SapphireExceptionpublic boolean getLockAttachment()
public void setLockAttachment(boolean lockAttachment)
lockAttachment - Set to true to lock the attachment and false to unlock itpublic static java.lang.String evaluateFileNameExpressions(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum,
ConnectionInfo connectionInfo,
java.lang.String input,
Attachment attachment)
public static java.lang.String evaluateFileNameExpressions(java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
int attachmentnum,
int auditsequence,
ConnectionInfo connectionInfo,
java.lang.String input,
Attachment attachment)
public static java.lang.String replaceDateTokens(java.lang.String filename)
public static java.lang.String replaceDbTokens(java.lang.String filename,
java.lang.String sdcid,
java.lang.String keyid1,
java.lang.String keyid2,
java.lang.String keyid3,
Attachment attachment,
ConnectionInfo connectionInfo)
public static java.lang.String replaceInvalidChars(java.lang.String tokens,
java.lang.String replacement)
public java.lang.String toString()
toString in class java.lang.Object