it.eng.spagobi.analiticalmodel.document
Class AnalyticalModelDocumentManagementAPI

java.lang.Object
  extended by it.eng.spagobi.analiticalmodel.document.AnalyticalModelDocumentManagementAPI

public class AnalyticalModelDocumentManagementAPI
extends java.lang.Object

Author:
Andrea Gioia (andrea.gioia@eng.it) This class considers all objects with the id property set and not equal to 0 as object that already exist in the database (see method isAnExistingDocument)

Field Summary
static java.lang.Integer MODIFIABLE
           
static java.lang.Integer MULTIVALUE
           
static java.lang.Integer REQUIRED
           
static java.lang.Integer VISIBLE
           
 
Constructor Summary
AnalyticalModelDocumentManagementAPI(it.eng.spago.security.IEngUserProfile userProfile)
           
 
Method Summary
 void addParameter(BIObject documentDescriptor, java.lang.Object analyticalDriverDescriptor, int priority)
          Add the analytical driver associated to the analyticalDriverDescriptor to the document associated to the documentDescriptor.
 void copyParameters(java.lang.Object sourceDocument, java.lang.Object destinationDocument)
          Copy all the parameters associated with sourceDocument to destinationDocument
 Parameter getAnalyticalDriver(java.lang.Object analyticalDriverDescriptor)
          Utility method.
 BIObject getDocument(java.lang.Object docDescriptor)
          Utility method.
 ObjMetadata getMetadataProperty(java.lang.Object matadataPropertyDescriptor)
          Utility method.
 boolean isAnExistingDocument(BIObject document)
           
 void propagateDatasetParameters(it.eng.spagobi.tools.dataset.bo.IDataSet dataset, BIObject document)
          This method add a parameter to the document for each parameter associated with the dataset.
 boolean saveDocument(BIObject document, ObjTemplate template)
           
 void saveDocumentMetadataProperties(java.lang.Object documentDescriptor, java.lang.Integer subObjectId, org.json.JSONArray metadataJSON)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUIRED

public static final java.lang.Integer REQUIRED

MODIFIABLE

public static final java.lang.Integer MODIFIABLE

MULTIVALUE

public static final java.lang.Integer MULTIVALUE

VISIBLE

public static final java.lang.Integer VISIBLE
Constructor Detail

AnalyticalModelDocumentManagementAPI

public AnalyticalModelDocumentManagementAPI(it.eng.spago.security.IEngUserProfile userProfile)
Method Detail

getDocument

public BIObject getDocument(java.lang.Object docDescriptor)
Utility method. Returns the document associated to the descriptor object.

Parameters:
docDescriptor - Could be the document itself (an object of type BIObject), its id (an object of type Integer) or its label (an object of type String)
Returns:
the document associated to the descriptor object if it exist, null otherwise.

getAnalyticalDriver

public Parameter getAnalyticalDriver(java.lang.Object analyticalDriverDescriptor)
Utility method. Returns the analytical driver associated to the descriptor object.

Parameters:
analyticalDriverDescriptor - Could be the analytical driver itself (an object of type Parameter) or its label (an object of type String)
Returns:
the analytical driver associated to the descriptor object if it exist, null otherwise.

getMetadataProperty

public ObjMetadata getMetadataProperty(java.lang.Object matadataPropertyDescriptor)
Utility method. Returns the metadata property associated to the descriptor object.

Parameters:
matadataPropertyDescriptor - Could be the metadata property's id (an object of type Integer) or its label (an object of type String)
Returns:
the analytical driver associated to the descriptor object if it exist, null otherwise.

isAnExistingDocument

public boolean isAnExistingDocument(BIObject document)
Parameters:
document - The document
Returns:
return true if the doocument's id property is set and not equal to 0. This method do not perform a real check on the database.

saveDocument

public boolean saveDocument(BIObject document,
                            ObjTemplate template)
Parameters:
document - The document to save (insert or modify)
template - The new template of the document
Returns:
true if the save operation perform an overwrite ( = modify an existing document ), false otherwise ( = insert a new document )

saveDocumentMetadataProperties

public void saveDocumentMetadataProperties(java.lang.Object documentDescriptor,
                                           java.lang.Integer subObjectId,
                                           org.json.JSONArray metadataJSON)
Parameters:
documentDescriptor - The descriptor of the target document
subObjectId - The id of the target subobject (optional). If it is nos specified the metadata properties will be applied to the main object
metadataJSON - The metadata properties to add. They are encoded as an array of object like the following one { meta_id: NUMBER , meta_name: STRING , meta_content: STRING } at least one between attributes meta_id and meta_name must be set. TODO use this method to refactor class SaveMetadataAction

copyParameters

public void copyParameters(java.lang.Object sourceDocument,
                           java.lang.Object destinationDocument)
Copy all the parameters associated with sourceDocument to destinationDocument

Parameters:
sourceDocument - can be an object of type BIObject or an Integer representing the id of the source document
destinationDocument - can be an object of type BIObject or an Integer representing the id of the destination document

propagateDatasetParameters

public void propagateDatasetParameters(it.eng.spagobi.tools.dataset.bo.IDataSet dataset,
                                       BIObject document)
This method add a parameter to the document for each parameter associated with the dataset. The added parameters will point to analytical drivers whose label match with the corresponding dataset parameter's name. If for one dataset parameter does not exist an analytical driver whose label match with the name of the parameter an exception will be thrown

Parameters:
dataset - the datset
document - the document

addParameter

public void addParameter(BIObject documentDescriptor,
                         java.lang.Object analyticalDriverDescriptor,
                         int priority)
Add the analytical driver associated to the analyticalDriverDescriptor to the document associated to the documentDescriptor. The document must be already present on the database. The name and the url of the added parameters are both equal to the analytical driver label. This method do not check if the document already have a parameter with this name.

Parameters:
documentDescriptor - can be the document itself(BIObject), the document id(Integer) or the document label(String)
analyticalDriverDescriptor - can be the analytical driver(Parameter) itself or its label (String)
priority -