com.tszadel.qctools4j.clients
Class AbstractClient

java.lang.Object
  extended by com.tszadel.qctools4j.clients.AbstractClient
Direct Known Subclasses:
BugClient, FieldDescriptionClient, TestClient, UserClient

public abstract class AbstractClient
extends Object

The common client.

Author:
tszadel

Field Summary
protected  QcConnectionImpl connection
          The connection to QC.
static int NONE
          No flag.
static int WITH_ATTACHMENTS
          Attachments have to be added.
static int WITH_CHILDREN
          Children have to be added.
 
Constructor Summary
AbstractClient(IQcConnection pConnection)
          Constructor.
 
Method Summary
protected  boolean canExecuteAction(PermissionEnum pPermission)
          Check if the user can execute the given action.
protected  void checkConnection()
          Check if the client is connected.
protected  void checkLogin()
          Check if the client is logged in.
protected  void checkPermission(PermissionEnum pPermission)
          Check if the current user can execute the given action on the given element.
protected  boolean containsFlag(int pFlag, int pValue)
          Check if a flag is contained in the value.
protected  String getEncodedString(String pString)
          Returns an encoded string to pass to the QC methods that disagree with blank space.
abstract  Map<String,FieldDescription> getFieldDescriptions()
          Returns the descriptions of the fields.
protected  void loadFields(com.mercury.qualitycenter.otaclient.IBaseField pQcEntity, Object pModel, boolean pWithAttachments)
          Fill the fields of the given model by processing annotation.
protected  List<Attachment> retrieveAttachments(com.mercury.qualitycenter.otaclient.IBaseFieldEx pQcEntity)
          Retrieve all attachments of the given entity.
protected  void retrieveCustomFields(Object pModel)
          Retrieve custom fields
protected  void storeAttachments(com.mercury.qualitycenter.otaclient.IBaseFieldEx pQcEntity, List<Attachment> pAttachmentList, boolean pSynchronize)
          Save all attachments of the given entity.
protected  void storeFields(com.mercury.qualitycenter.otaclient.IBaseField pQcEntity, Object pModel, boolean pWithAttachments)
          Store the fields of the given model to the given entity..
protected  Attachment toAttachment(com.mercury.qualitycenter.otaclient.IAttachment pAttachment)
          Convert the Attachment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
No flag.

See Also:
Constant Field Values

WITH_ATTACHMENTS

public static final int WITH_ATTACHMENTS
Attachments have to be added.

See Also:
Constant Field Values

WITH_CHILDREN

public static final int WITH_CHILDREN
Children have to be added.

See Also:
Constant Field Values

connection

protected final QcConnectionImpl connection
The connection to QC.

Constructor Detail

AbstractClient

public AbstractClient(IQcConnection pConnection)
Constructor.

Parameters:
pConnection - The QC Connection.
Method Detail

getFieldDescriptions

public abstract Map<String,FieldDescription> getFieldDescriptions()
                                                           throws QcException
Returns the descriptions of the fields.

Returns:
The description of the fields (key=name of the field, value=description of the field).
Throws:
QcException - Qc Error.

canExecuteAction

protected boolean canExecuteAction(PermissionEnum pPermission)
                            throws QcException
Check if the user can execute the given action.

Parameters:
pPermission - The permission.
Returns:
True if the user can execute the action, false otherwise.
Throws:
QcException - Error.

checkConnection

protected void checkConnection()
                        throws QcException
Check if the client is connected.

Throws:
QcException - Connection error.

checkLogin

protected void checkLogin()
                   throws QcException
Check if the client is logged in.

Throws:
QcException - Connection error.

checkPermission

protected void checkPermission(PermissionEnum pPermission)
                        throws PermissionException,
                               QcException
Check if the current user can execute the given action on the given element.

Parameters:
pPermission - The permission.
Throws:
PermissionException - Permission fails.
QcException - QC error.

containsFlag

protected boolean containsFlag(int pFlag,
                               int pValue)
Check if a flag is contained in the value.

Parameters:
pFlag - The flag.
pValue - The value.
Returns:
True if the flag is in the value.

getEncodedString

protected String getEncodedString(String pString)
Returns an encoded string to pass to the QC methods that disagree with blank space.

Parameters:
pString - The path.
Returns:
The string encoded.

loadFields

protected void loadFields(com.mercury.qualitycenter.otaclient.IBaseField pQcEntity,
                          Object pModel,
                          boolean pWithAttachments)
                   throws QcException
Fill the fields of the given model by processing annotation.

Parameters:
pQcEntity - The QC Object.
pModel - The model whose fields will be set.
pWithAttachments - True if the attachments have to be downloaded.
Throws:
QcException - Qc Error.
See Also:
QcField

retrieveAttachments

protected List<Attachment> retrieveAttachments(com.mercury.qualitycenter.otaclient.IBaseFieldEx pQcEntity)
                                        throws QcException
Retrieve all attachments of the given entity.

Parameters:
pQcEntity - The entity.
Returns:
The attachments found.
Throws:
QcException - Qc error.

retrieveCustomFields

protected void retrieveCustomFields(Object pModel)
                             throws QcException
Retrieve custom fields

Parameters:
pModel - The model.
Throws:
QcException - Qc Error.

storeAttachments

protected void storeAttachments(com.mercury.qualitycenter.otaclient.IBaseFieldEx pQcEntity,
                                List<Attachment> pAttachmentList,
                                boolean pSynchronize)
                         throws QcException
Save all attachments of the given entity.

Parameters:
pQcEntity - The entity.
pAttachmentList - The attachments to save.
pSynchronize - True if the current list of attachments is the full list of attachments (deletion can be done)
Throws:
QcException - Qc error.

storeFields

protected void storeFields(com.mercury.qualitycenter.otaclient.IBaseField pQcEntity,
                           Object pModel,
                           boolean pWithAttachments)
                    throws QcException
Store the fields of the given model to the given entity..

Parameters:
pQcEntity - The QC Object.
pModel - The model whose fields will be get.
pWithAttachments - True if the attachments have to be uploaded.
Throws:
QcException - Qc Error.
See Also:
QcField

toAttachment

protected Attachment toAttachment(com.mercury.qualitycenter.otaclient.IAttachment pAttachment)
                           throws QcException
Convert the Attachment.

Parameters:
pAttachment - The Qc Attachment.
Returns:
The attachment.
Throws:
QcException - QC Error.