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

Go to the SVN repository for this file.

1 /* $Id: remove_unverified.cpp 47154 2022-09-26 17:58:36Z 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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 #include <objmgr/scope.hpp>
35 
38 
39 // CRemoveUnverified
40 
41 void CRemoveUnverified::ApplyToCSeq_entry (objects::CSeq_entry_Handle tse, const CSeq_entry& se, CCmdComposite* composite)
42 {
43 
45  {
46  if ((*it)->IsUser())
47  {
49  bool modified = ApplyToUserObject((*it)->GetUser(),seh);
50  if (modified)
51  {
52  CIRef<IEditCommand> cmdDelDesc(new CCmdDelDesc(seh, **it));
53  composite->AddCommand(*cmdDelDesc);
54  }
55  }
56  }
57 
58  if (se.IsSet()) {
60  ApplyToCSeq_entry (tse, **it, composite);
61  }
62  }
63 }
64 
65 void CRemoveUnverified::apply_to_seq_and_feat(objects::CSeq_entry_Handle tse, CCmdComposite* composite)
66 {
67  ApplyToCSeq_entry (tse, *(tse.GetCompleteSeq_entry()), composite);
68 }
69 
70 bool CRemoveUnverified::apply(objects::CSeq_entry_Handle tse, ICommandProccessor* cmdProcessor, string title)
71 {
72  if (tse) {
73  CRef<CCmdComposite> composite(new CCmdComposite(title));
74  apply_to_seq_and_feat(tse,composite);
75  cmdProcessor->Execute(composite.GetPointer());
76  return true;
77  }
78  else
79  return false;
80 }
81 
82 
84 {
85  bool found = false;
86  if (user.IsSetType() && user.GetType().IsStr() && user.GetType().GetStr() == "Unverified") // User-object.type.str
87  found = true;
88  return found;
89 }
90 
91 
92 // CRemoveUnreviewed
94 {
95  CRef<CCmdComposite> composite(new CCmdComposite("Remove unreviewed user objects"));
96  x_ApplyToSeq_entry(tse, *(tse.GetCompleteSeq_entry()), composite);
97  return composite;
98 }
99 
101 {
103  if ((*it)->IsUser()) {
105  bool modified = x_ApplyToUserObject((*it)->GetUser(), seh);
106  if (modified) {
107  CIRef<IEditCommand> cmdDelDesc(new CCmdDelDesc(seh, **it));
108  composite->AddCommand(*cmdDelDesc);
109  }
110  }
111  }
112 
113  if (se.IsSet()) {
115  x_ApplyToSeq_entry(tse, **it, composite);
116  }
117  }
118 }
119 
121 {
122  return (user.IsSetType() && user.GetType().IsStr() && user.GetType().GetStr() == "Unreviewed");
123 }
124 
125 
void AddCommand(IEditCommand &command)
bool x_ApplyToUserObject(const objects::CUser_object &user, objects::CSeq_entry_Handle seh)
void x_ApplyToSeq_entry(objects::CSeq_entry_Handle tse, const objects::CSeq_entry &se, CCmdComposite *composite)
CRef< CCmdComposite > Apply(objects::CSeq_entry_Handle tse)
bool apply(objects::CSeq_entry_Handle tse, ICommandProccessor *cmdProcessor, string title)
void ApplyToCSeq_entry(objects::CSeq_entry_Handle tse, const objects::CSeq_entry &se, CCmdComposite *composite)
void apply_to_seq_and_feat(objects::CSeq_entry_Handle tse, CCmdComposite *composite)
virtual bool ApplyToUserObject(const objects::CUser_object &user, objects::CSeq_entry_Handle seh)
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CScope & GetScope(void) const
Get scope this handle belongs to.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TType & GetType(void) const
Get the Type member data.
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
USING_SCOPE(objects)
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define FOR_EACH_SEQDESC_ON_SEQENTRY(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQENTRY EDIT_EACH_SEQDESC_ON_SEQENTRY.
Modified on Fri Sep 20 14:58:33 2024 by modify_doxy.py rev. 669887