fw4spl
V1ToFwMedDataStudyV1.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include <fwAtoms/Numeric.hpp>
8 #include <fwAtoms/Numeric.hxx>
9 #include <fwAtoms/String.hpp>
10 
11 #include "fwStructuralPatch/fwData/Study/V1ToFwMedDataStudyV1.hpp"
12 
13 namespace fwStructuralPatch
14 {
15 
16 namespace fwData
17 {
18 
19 namespace Study
20 {
21 
23 {
24  m_originClassname = "::fwData::Study";
25  m_targetClassname = "::fwMedData::Study";
26  m_originVersion = "1";
27  m_targetVersion = "1";
28 }
29 
30 // ----------------------------------------------------------------------------
31 
33 {
34 }
35 
36 // ----------------------------------------------------------------------------
37 
39 {
40 }
41 
42 // ----------------------------------------------------------------------------
43 
44 void V1ToFwMedDataStudyV1::apply(const ::fwAtoms::Object::sptr& previous,
45  const ::fwAtoms::Object::sptr& current,
46  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
47 {
48  IStructuralPatch::apply(previous, current, newVersions);
49 
50  // Update object version
51  this->updateVersion(current);
52 
53  // Create helper
54  ::fwAtomsPatch::helper::Object helper(current);
55 
56  helper.removeAttribute("hospital");
57  helper.removeAttribute("modality");
58  helper.removeAttribute("acquisition_zone");
59  helper.removeAttribute("ris_id");
60  helper.removeAttribute("db_id");
61  helper.removeAttribute("acquisitions");
62 
63  helper.renameAttribute("uid", "instance_uid");
64 
65  helper.addAttribute("referring_physician_name", ::fwAtoms::String::New(""));
66  helper.addAttribute("patient_age", ::fwAtoms::String::New(""));
67 }
68 
69 } // namespace Study
70 
71 } // namespace fwData
72 
73 } // namespace fwStructuralPatch
74 
75 
FWATOMSPATCH_API void updateVersion(std::shared_ptr< ::fwAtoms::Object > current)
Updates the version of the patched object.
static FWATOMS_API String::sptr New(std::string value)
Construct a new Object represented a string.
FWATOMSPATCH_API void renameAttribute(const std::string &name, const std::string &newName, conditions::Abstract::sptr condition=conditions::Abstract::New())
Renames an attribute.
FWATOMSPATCH_API void removeAttribute(const std::string &name, conditions::Abstract::sptr condition=conditions::Abstract::New())
Removes an attribute.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
std::string m_targetClassname
Target type.
FWATOMSPATCH_API IStructuralPatch()
Constructor.
std::string m_originClassname
Origin classname of the object.
Definition: IPatch.hpp:64
Contains creators and structural patches.
Definition: Landmarks1.hpp:13
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
FWSTRUCTURALPATCH_API V1ToFwMedDataStudyV1()
Constructor.
Transforms a ::fwData::Study to a fwMedData::Study.
FWATOMSPATCH_API void addAttribute(const std::string &name,::fwAtoms::Base::sptr value, conditions::Abstract::sptr condition=conditions::Abstract::New())
Adds a new attribute in the current object.
std::string m_targetVersion
Target version.
Contains the representation of the data objects used in the framework.
virtual FWSTRUCTURALPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.