LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AbstractXmlReaderClient.cpp
Go to the documentation of this file.
1// Copyright 2004-2021 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
10#include "XmlReaderException.h"
11
12using namespace Lima;
13using namespace Lima::Common;
15
16namespace Lima
17{
18namespace XmlReader
19{
20
22 XMLConfigurationFileParser* configuration)
23{
26
27 // Read list of declared standard properties
28 try
29 {
30 GroupConfigurationStructure& groupConf = configuration->getModuleGroupConfiguration("lp-structuredXmlreaderclient",
31 "documentXMLParser" );
32 std::deque<std::string> standardPropertyList= groupConf.getListsValueAtKey ( "standard-properties-list" );
33 // get list of identifier of attributes from config file
34 for ( std::deque<std::string>::const_iterator attributeIdentifier = standardPropertyList.begin();
35 attributeIdentifier != standardPropertyList.end(); attributeIdentifier++ )
36 {
37 const std::string docPropertyName = *attributeIdentifier;
38 GroupConfigurationStructure& propertyGroupConf = configuration->getModuleGroupConfiguration("lp-structuredXmlreaderclient",
39 docPropertyName );
40 DocPropertyPublicInfo docPropertyInfo;
41 docPropertyInfo.isInternal = false;
42 try {
43 docPropertyInfo.storageType = propertyGroupConf.getParamsValueAtKey ( "storageType" );
44 }
45 catch ( NoSuchParam& e )
46 {
47#ifdef DEBUG_LP
49 LWARN << "no param 'storageType' in DocumentPropertyType group for " << docPropertyName;
50#endif
51 }
52 try {
53 docPropertyInfo.cardinality = propertyGroupConf.getParamsValueAtKey ( "cardinality" );
54 }
55 catch ( NoSuchParam& e )
56 {
57#ifdef DEBUG_LP
59 LDEBUG << "no param 'cardinality' in DocumentPropertyType group for " << docPropertyName;
60#endif
61 }
62 try {
63 docPropertyInfo.description = propertyGroupConf.getParamsValueAtKey ( "description" );
64 }
65 catch ( NoSuchParam& e )
66 {
67#ifdef DEBUG_LP
69 LDEBUG << "no param 'description' in DocumentPropertyType group for " << docPropertyName;
70#endif
71 }
72 try {
73 std::string val = propertyGroupConf.getParamsValueAtKey ( "isInternal" );
74 if (val=="true" || val=="yes" || val=="1")
75 docPropertyInfo.isInternal = true;
76 }
77 catch ( NoSuchParam& e )
78 {
79#ifdef DEBUG_LP
81 LDEBUG << "no param 'isInternal' in DocumentPropertyType group for " << docPropertyName;
82#endif
83 }
84 m_standardPrprtyInfos.insert( std::make_pair(docPropertyName , docPropertyInfo ) );
85 }
86 }
87 catch ( NoSuchGroup & e )
88 {
90 LWARN << "AbstractXmlReaderClient: NoSuchGroup Exception: " << e.what();
91 }
92 catch ( NoSuchList & e )
93 {
95 LWARN << "AbstractXmlReaderClient: NoSuchList Exception: standard-properties-list";
96 }
97
98 // Read list of specific attribute
99 try
100 {
101 GroupConfigurationStructure& groupConf = configuration->getModuleGroupConfiguration("lp-structuredXmlreaderclient",
102 "documentXMLParser" );
103 std::deque<std::string> extendedPropertyList= groupConf.getListsValueAtKey ( "extended-properties-list" );
104 // get list of identifier of attributes from config file
105 for ( std::deque<std::string>::const_iterator attributeIdentifier = extendedPropertyList.begin();
106 attributeIdentifier != extendedPropertyList.end(); attributeIdentifier++ )
107 {
108 const std::string docPropertyName = *attributeIdentifier;
109 GroupConfigurationStructure& propertyGroupConf = configuration->getModuleGroupConfiguration("lp-structuredXmlreaderclient",
110 docPropertyName );
111 DocPropertyPublicInfo docPropertyInfo;
112 docPropertyInfo.isInternal = false;
113 try {
114 docPropertyInfo.storageType = propertyGroupConf.getParamsValueAtKey ( "storageType" );
115 }
116 catch ( NoSuchParam& e )
117 {
118#ifdef DEBUG_LP
120 LWARN << "no param 'storageType' in DocumentPropertyType group for " << docPropertyName;
121#endif
122 }
123 try {
124 docPropertyInfo.cardinality = propertyGroupConf.getParamsValueAtKey ( "cardinality" );
125 }
126 catch ( NoSuchParam& e )
127 {
128#ifdef DEBUG_LP
130 LDEBUG << "no param 'cardinality' in DocumentPropertyType group for " << docPropertyName;
131#endif
132 }
133 try {
134 docPropertyInfo.description = propertyGroupConf.getParamsValueAtKey ( "description" );
135 }
136 catch ( NoSuchParam& e )
137 {
138#ifdef DEBUG_LP
140 LDEBUG << "no param 'description' in DocumentPropertyType group for " << docPropertyName;
141#endif
142 }
143 try {
144 std::string val = propertyGroupConf.getParamsValueAtKey ( "isInternal" );
145 if (val=="true" || val=="yes" || val=="1")
146 docPropertyInfo.isInternal = true;
147 }
148 catch ( NoSuchParam& e )
149 {
150#ifdef DEBUG_LP
152 LDEBUG << "no param 'isInternal' in DocumentPropertyType group for " << docPropertyName;
153#endif
154 }
155 m_extendedPrprtyInfos.insert( std::make_pair(docPropertyName , docPropertyInfo ) );
156 }
157 }
158 catch ( NoSuchGroup & e )
159 {
161 LWARN << "AbstractXmlReaderClient: NoSuchGroup Exception: " << e.what();
162 }
163 catch ( NoSuchList & e )
164 {
166 LWARN << "AbstractXmlReaderClient: NoSuchList Exception: extended-properties-list";
167 }
168
169
170}
171
172} // XmlReader
173} // Lima
#define LWARN
Definition LimaCommon.h:160
#define LDEBUG
Definition LimaCommon.h:157
#define XMLREADERCLIENTLOGINIT
std::deque< std::string > & getListsValueAtKey(const std::string &key)
return a message when a 'group' was not found
return a message when a 'param' was not found
Parser class for the lima's xml configuration files.
GroupConfigurationStructure & getModuleGroupConfiguration(const std::string &moduleName, const std::string &groupName)
virtual const char * what() const override
Definition LimaCommon.h:280
void setDocumentPropertyConfiguration(Lima::Common::XMLConfigurationFiles::XMLConfigurationFileParser *configuration)
Extract from configuration the subset of document property attributes from both standard-properties-l...
NAUTITIA.
Store a subset of document property attributes extracted from configuration, for the purpose of publi...