comparison Core/JobsEngine/GenericJobUnserializer.cpp @ 2656:a6d3e45eeff5 jobs

SerializationToolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 Jun 2018 18:25:23 +0200
parents c196d76cb8fa
children 2540ac79ab6c
comparison
equal deleted inserted replaced
2655:c196d76cb8fa 2656:a6d3e45eeff5
34 #include "../PrecompiledHeaders.h" 34 #include "../PrecompiledHeaders.h"
35 #include "GenericJobUnserializer.h" 35 #include "GenericJobUnserializer.h"
36 36
37 #include "../Logging.h" 37 #include "../Logging.h"
38 #include "../OrthancException.h" 38 #include "../OrthancException.h"
39 #include "../SerializationToolbox.h"
39 40
40 #include "Operations/LogJobOperation.h" 41 #include "Operations/LogJobOperation.h"
41 #include "Operations/NullOperationValue.h" 42 #include "Operations/NullOperationValue.h"
42 #include "Operations/StringOperationValue.h" 43 #include "Operations/StringOperationValue.h"
43 44
44 namespace Orthanc 45 namespace Orthanc
45 { 46 {
46 IJob* GenericJobUnserializer::UnserializeJob(const Json::Value& source) 47 IJob* GenericJobUnserializer::UnserializeJob(const Json::Value& source)
47 { 48 {
48 const std::string type = ReadString(source, "Type"); 49 const std::string type = SerializationToolbox::ReadString(source, "Type");
49 50
50 LOG(ERROR) << "Cannot unserialize job of type: " << type; 51 LOG(ERROR) << "Cannot unserialize job of type: " << type;
51 throw OrthancException(ErrorCode_BadFileFormat); 52 throw OrthancException(ErrorCode_BadFileFormat);
52 } 53 }
53 54
54 55
55 IJobOperation* GenericJobUnserializer::UnserializeOperation(const Json::Value& source) 56 IJobOperation* GenericJobUnserializer::UnserializeOperation(const Json::Value& source)
56 { 57 {
57 const std::string type = ReadString(source, "Type"); 58 const std::string type = SerializationToolbox::ReadString(source, "Type");
58 59
59 if (type == "Log") 60 if (type == "Log")
60 { 61 {
61 return new LogJobOperation; 62 return new LogJobOperation;
62 } 63 }
68 } 69 }
69 70
70 71
71 JobOperationValue* GenericJobUnserializer::UnserializeValue(const Json::Value& source) 72 JobOperationValue* GenericJobUnserializer::UnserializeValue(const Json::Value& source)
72 { 73 {
73 const std::string type = ReadString(source, "Type"); 74 const std::string type = SerializationToolbox::ReadString(source, "Type");
74 75
75 if (type == "String") 76 if (type == "String")
76 { 77 {
77 return new StringOperationValue(ReadString(source, "Content")); 78 return new StringOperationValue(SerializationToolbox::ReadString(source, "Content"));
78 } 79 }
79 else if (type == "Null") 80 else if (type == "Null")
80 { 81 {
81 return new NullOperationValue; 82 return new NullOperationValue;
82 } 83 }