56 m_SrvLocator(srv_locator),
72 LOG_POST(
Info <<
"CProjectServiceTestTask::x_Run() - BEGIN");
90 LOG_POST(
Info <<
"CProjectServiceTestTask::x_Run() - BEGIN(completed)");
101 m_ProjectService(service),
109 sType =
"eCreateItems";
113 sType =
"eModifyItems";
117 sType =
"eDeleteItems";
121 sType =
"ePrintItems";
125 m_Descr =
"Test Job - " + sType;
131 static const char* kLogMsg =
"CProjectServiceTestJob::Run() - exception in x_Run() ";
132 static string kErrorMsg =
"Unhandled exception in CProjectServiceTestJob::Run()";
176 if(err_msg.empty()) {
179 string s = kErrorMsg + err_msg;
187 vector<int> projectIds;
190 if (doc && doc->IsLoaded()) {
191 projectIds.push_back(doc->GetId());
204 doc->SetDescr().SetTitle(new_name);
208 doc->SetCreateDate(date);
209 doc->SetModifiedDate(date);
214 srv->x_OnProjectChanged(doc->GetId());
215 srv->x_OnWorkspaceChanged(ws.
GetId());
223 static int item_counter = 0;
240 if (projectIds.empty()) {
247 for (
size_t i = 0;
i < projectIds.size();
i++) {
253 static int kItemsN = 2;
254 LOG_POST(
Info <<
"Creating " << kItemsN <<
" items in project " << doc->GetDescr().GetTitle());
256 for(
int j = 0; j < kItemsN; j++ ) {
265 doc->AddItem(*item, data_folder);
268 doc->SetDirty(
true );
297 for (
size_t i = 0;
i < projectIds.size();
i++) {
300 LOG_POST(
Info <<
"Renaming items " << doc->GetDescr().GetTitle());
308 if ((*it)->IsSetLabel())
309 name = (*it)->GetLabel();
311 string::size_type pos = name.find_first_of(
':');
312 if(pos != string::npos) {
316 (*it)->SetLabel(doc->MakeUniqueItemLabel(name));
320 doc->SetDirty(
true );
348 for (
size_t i = 0;
i < projectIds.size();
i++) {
351 LOG_POST(
Info <<
"Deleting items from project " << doc->GetDescr().GetTitle());
355 vector<int> projectItems;
357 projectItems.push_back((*it)->GetId());
359 ITERATE(vector<int>, it, projectItems) {
368 doc->SetDirty(
true );
394 for (
size_t i = 0;
i < projectIds.size();
i++) {
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CAppJob - default implementation of IAppJob that could be used as a base class.
CAppTask - default implementation of IAppTask, use it as a base class for custom tasks.
void DetachProjectItem(objects::CProjectItem *item)
virtual void CreateProjectScope()
bool RemoveProjectItem(objects::CProjectItem *item)
void AttachProjectItem(objects::CProjectItem *item)
string MakeUniqueProjectTitle(const string &label) const
Create a unique label for a project.
CProjectItem * FindProjectItemById(CProjectItem::TId id)
void SetObject(CSerialObject &object)
wrapper for setting the object pointed to by this item
CProjectServiceTestJob(CProjectService *service, EType type, int sleep_ms)
CProjectServiceTestJob.
CProjectService * m_ProjectService
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
IServiceLocator * m_SrvLocator
overriding CAppTask::x_Run()
CProjectServiceTestTask(IServiceLocator *srv_locator)
virtual ETaskState x_Run()
override this function in derived classes
virtual ~CProjectServiceTestTask()
CProjectService * m_Service
CProjectService - a service providing API for operations with Workspaces and Projects.
CRef< objects::CGBWorkspace > GetGBWorkspace()
Template class for iteration on objects of class C (non-medifiable version)
IServiceLocator - an abstract mechanism for locating services.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
const string & GetMsg(void) const
Get message string.
string ReportAll(TDiagPostFlags flags=eDPF_Exception) const
Report all exceptions.
void Info(CExceptionArgs_Base &args)
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
ETaskState
List of task states defining the task management FSM.
@ eCompleted
successfully finished
CRef< CAppJobError > m_Error
string m_Descr
mutex to sync our internals
static CAppJobDispatcher & GetInstance()
virtual void x_ResetState()
virtual bool IsCanceled() const override
EJobState
Job states (describe FSM)
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
virtual string GetDescr() const override
Returns a human readable description of the Job (optional)
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
@ eCurrent
Use current time. See also CCurrentTime.
static const char label[]
list< CRef< CProjectItem > > TItems
void SetLabel(const TLabel &value)
Assign a value to Label data member.
TId GetId(void) const
Get the Id member data.
const TLabel & GetLabel(void) const
Get the Label member data.
bool CanGetItems(void) const
Check if it is safe to call GetItems method.
const TItems & GetItems(void) const
Get the Items member data.
TItems & SetItems(void)
Assign a value to Items data member.
void SetWorkspace(TWorkspace &value)
Assign a value to Workspace data member.
void SleepMilliSec(unsigned long ml_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static CRef< CGBDocument > s_CreateNewProject(CProjectService *srv, CGBWorkspace &ws)
static vector< int > s_GetProjectIds(const CWorkspaceFolder &folder)