NCBI C++ ToolKit
srcedit_tool.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: srcedit_tool.cpp 46706 2021-09-09 19:54:51Z asztalos $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Colleen Bollin, based on a file by Roman Katargin
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 
34 
41 #include <objects/biblio/Affil.hpp>
45 
47 
48 #include <serial/typeinfo.hpp>
49 
51 
53 #include <gui/objutils/label.hpp>
54 
56 
57 
60 
61 ///////////////////////////////////////////////////////////////////////////////
62 /// CSrcEditTool
64 : CAlgoToolManagerBase("Bulk Source Editing",
65  "",
66  "Bulk Source Editing",
67  "Assistant for preparing sequences "
68  "for submission to GenBank",
69  "SRCEDIT",
70  "Bulk Source Editing"),
71  m_Panel()
72 {
73  m_Descriptor.SetLogEvent("tools");
74 }
75 
77 {
78  return "srcedit_tool";
79 }
80 
81 
83 {
84  return "Submission Preparation Tool";
85 }
86 
88 {
90 
91  m_Panel = NULL;
92 }
93 
95 {
96  m_Panel = NULL;
98 }
99 
101 {
102  return m_State == eParams;
103 }
104 
106 {
107  if (m_State != eParams || action != eNext)
108  return CAlgoToolManagerBase::DoTransition(action);
109 
110  if (x_GetParamsPanel()->TransferDataFromWindow()) {
112  return true;
113  }
114 
115  return false;
116 }
117 
119 {
121  if (!job)
122  return 0;
123 
125  CSelectProjectOptions options;
126  options.Set_CreateNewProject();
127  CRef<CDataLoadingAppTask> task(new CDataLoadingAppTask(srv, options, *job));
128  return task.Release();
129 }
130 
132 {
133  if (m_Panel == NULL) {
135 
136  m_Panel = new CSrcEditPanel();
137  m_Panel->Hide(); // to reduce flicker
141 
142  m_Panel->SetRegistryPath(m_RegPath + ".ParamsPanel");
144  }
145  return true;
146 }
147 
149 {
150  return true;
151 }
152 
154 {
155  m_Objects.clear();
156 
157  ITERATE(vector<TConstScopedObjects>, it, m_InputObjects) {
158  ITERATE(TConstScopedObjects, it2, *it) {
159  const CObject* ptr = it2->object.GetPointer();
160  if (dynamic_cast<const CSeq_entry*>(ptr) ||
161  dynamic_cast<const CSeq_annot*>(ptr) ||
162  dynamic_cast<const CSeq_submit*>(ptr) ||
163  dynamic_cast<const CSeq_id*>(ptr))
164  m_Objects.push_back(*it2);
165  }
166  }
167 }
168 
170 {
171  return m_Panel;
172 }
173 
175 {
176  return &m_Params;
177 }
178 
179 ///////////////////////////////////////////////////////////////////////////////
180 /// CCleanupJob
182 {
183 public:
184  CSrcEditJob (const CSrcEditParams& params);
185 
186 protected:
187  virtual void x_CreateProjectItems(); // overriding virtual function
188 
189 protected:
191 };
192 
194 {
195  if (m_Panel) m_Params = m_Panel->GetData();
196  CSrcEditJob* job = new CSrcEditJob(m_Params);
197  return job;
198 }
199 
201 : m_Params(params)
202 {
203  CFastMutexGuard lock(m_Mutex);
204 
205  m_Descr = "Submission Preparation Job"; //TODO
206 }
207 
209 {
210  //bool error_occurred = false;
211  string errmsg = "";
212  string changelist = "";
214  vector<CRef<objects::CSeq_entry> > entries;
215 
217  const CObject* ptr = it->object.GetPointer();
218 
219  /// CSeq_entry
220  const objects::CSeq_entry* seqEntry = dynamic_cast<const objects::CSeq_entry*>(ptr);
221  if (seqEntry) {
222  CRef<objects::CSeq_entry> e(new objects::CSeq_entry());
223  e->Assign(*seqEntry);
224  entries.push_back(e);
225  } else {
226  const objects::CSeq_submit* seqsubmit = dynamic_cast<const objects::CSeq_submit*>(ptr);
227  if (seqsubmit) {
228  submit.Reset(new objects::CSeq_submit());
229  submit->Assign(*submit);
230  }
231  }
232  }
233  if (!submit) {
234  submit = new objects::CSeq_submit();
235  submit->SetSub().SetContact().SetFirst_name("");
236  submit->SetSub().SetContact().SetLast_name("");
237  CRef<CAuthor> new_auth(new CAuthor());
238  new_auth->SetName().SetName().SetLast("");
239  new_auth->SetName().SetName().SetFirst("");
240  submit->SetSub().SetCit().SetAuthors().SetNames().SetStd().push_back(new_auth);
241  }
242  ITERATE (vector<CRef<objects::CSeq_entry> >, it, entries) {
243  submit->SetData().SetEntrys().push_back (*it);
244  }
245  CRef<CProjectItem> item(new CProjectItem());
246  item->SetItem().SetSubmit(*submit);
247 
249 
250  AddProjectItem(*item);
251 
252 }
253 
254 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAlgoToolManagerBase This is base class for simple algorithmic tool managers.
CUIObject m_Descriptor
describes the Manager's UI properties
EState m_State
tool manager state (int the Run Tool wizard)
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual void InitUI()
override this function in a derived class and initialize extra members
string m_RegPath
registry path to the settings
wxWindow * m_ParentWindow
a window that will serve as a parent for our panels
virtual void CleanUI()
override this function in a derived class and clean extra members
vector< TConstScopedObjects > m_InputObjects
original input objects, the tool needs to select a subset of objects that can serve as valid input
CAlgoToolManagerParamsPanel.
virtual void SetRegistryPath(const string &reg_path)
CAlgoToolManagerParamsPanel.
CAuthor –.
Definition: Author.hpp:59
CDataLoadingAppJob - a base class for Jobs loading data into projects.
void AddProjectItem(objects::CProjectItem &item)
CRef< objects::CScope > m_Scope
CDataLoadingAppTask - a task that executes CDataLoadingAppJob.
CObject –.
Definition: ncbiobj.hpp:180
CProjectService - a service providing API for operations with Workspaces and Projects.
CRef –.
Definition: ncbiobj.hpp:618
CProjectSelectOptions - describes how new Project Items shall be added to a workspace.
void Set_CreateNewProject(const string &folder=kEmptyStr)
Definition: Seq_entry.hpp:56
CCleanupJob.
CSrcEditJob(const CSrcEditParams &params)
virtual void x_CreateProjectItems()
override this function in derived classes and populate m_Items.
CSrcEditParams m_Params
bool Create(wxWindow *parent, wxWindowID id=10011, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void SetObjects(TConstScopedObjects *objects)
CSrcEditParams & GetData()
Data access.
virtual void LoadSettings()
void SetData(const CSrcEditParams &data)
IAppTask.
Definition: app_task.hpp:83
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
virtual void InitUI()
override this function in a derived class and initialize extra members
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual IRegSettings * x_GetParamsAsRegSetting()
return a pointer to Parameters object as IRegSettings interface
TConstScopedObjects m_Objects
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual void CleanUI()
override this function in a derived class and clean extra members
virtual CDataLoadingAppJob * x_CreateLoadingJob()
factory method for creating the job that executes the tool algorithm override in derived classes
TConstScopedObjects m_Objects
virtual bool x_ValidateParams()
validates user input in Parameters panel, report errors if any
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
CSrcEditTool()
CSrcEditTool.
virtual bool x_CreateParamsPanelIfNeeded()
returns / creates Parameters panel, override in derived classes see cpp file for example
CSrcEditParams m_Params
virtual void x_SelectCompatibleInputObjects()
CSrcEditPanel * m_Panel
virtual CAlgoToolManagerParamsPanel * x_GetParamsPanel()
returns a pointer to the parameters panel, override in derived classes
string m_Descr
mutex to sync our internals
static void SetLabelByData(objects::CProjectItem &item, objects::CScope *scope=NULL)
Definition: label.cpp:121
CFastMutex m_Mutex
virtual void SetLogEvent(const string &log_event)
Definition: ui_object.cpp:118
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
Definition: ncbiobj.hpp:846
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void SetName(TName &value)
Assign a value to Name data member.
Definition: Author_.cpp:81
void SetItem(TItem &value)
Assign a value to Item data member.
The Object manager core.
USING_SCOPE(ncbi::objects)
static wxAcceleratorEntry entries[3]
Modified on Mon May 20 05:02:50 2024 by modify_doxy.py rev. 669887