----------------------------------------------------------------------------- Read the MetaData from the Config File -----------------------------------------------------------------------------
| 4088 | // Read the MetaData from the Config File |
| 4089 | //----------------------------------------------------------------------------- |
| 4090 | void Node::ReadMetaDataFromXML(TiXmlElement const* _valueElement) { |
| 4091 | TiXmlElement const* ccElement = _valueElement->FirstChildElement(); |
| 4092 | while( ccElement ) |
| 4093 | { |
| 4094 | if(!strcmp( ccElement->Value(), "MetaData" ) ) |
| 4095 | { |
| 4096 | TiXmlElement const* metadata = ccElement->FirstChildElement(); |
| 4097 | while (metadata) { |
| 4098 | if( !strcmp( metadata->Value(), "MetaDataItem" ) ) |
| 4099 | { |
| 4100 | string name = metadata->Attribute( "name" ); |
| 4101 | if (GetMetaDataId(name) == MetaData_Invalid) { |
| 4102 | Log::Write(LogLevel_Warning, m_nodeId, "Invalid MetaData Name in Config: %s", name.c_str()); |
| 4103 | metadata = metadata->NextSiblingElement(); |
| 4104 | continue; |
| 4105 | } |
| 4106 | /* these are the MetaData that have type/id entries */ |
| 4107 | switch (GetMetaDataId(name)) { |
| 4108 | case MetaData_ZWProductPage_URL: |
| 4109 | case MetaData_Identifier: |
| 4110 | case MetaData_Frequency: |
| 4111 | { |
| 4112 | int intVal; |
| 4113 | uint16_t type = 0; |
| 4114 | uint16_t id = 0; |
| 4115 | if( TIXML_SUCCESS == metadata->QueryIntAttribute( "type", &intVal ) ) |
| 4116 | { |
| 4117 | type = (uint16_t)intVal; |
| 4118 | } |
| 4119 | if( TIXML_SUCCESS == metadata->QueryIntAttribute( "id", &intVal ) ) |
| 4120 | { |
| 4121 | id = (uint16_t)intVal; |
| 4122 | } |
| 4123 | if ((type != GetProductType()) || |
| 4124 | (id != GetProductId()) ) { |
| 4125 | metadata = metadata->NextSiblingElement(); |
| 4126 | continue; |
| 4127 | } |
| 4128 | break; |
| 4129 | } |
| 4130 | /* for the rest, just take the standard entry */ |
| 4131 | default: |
| 4132 | break; |
| 4133 | } |
| 4134 | this->m_metadata[GetMetaDataId(name)] = metadata->GetText(); |
| 4135 | } else if (!strcmp( metadata->Value(), "ChangeLog" )) { |
| 4136 | TiXmlElement const* entry = metadata->FirstChildElement("Entry"); |
| 4137 | while (entry) { |
| 4138 | ChangeLogEntry cle; |
| 4139 | cle.author = entry->Attribute("author"); |
| 4140 | cle.date = entry->Attribute("date"); |
| 4141 | cle.description = entry->GetText(); |
| 4142 | metadata->QueryIntAttribute( "id", &cle.revision ); |
| 4143 | m_changeLog[cle.revision] = cle; |
| 4144 | entry = entry->NextSiblingElement("Entry"); |
| 4145 | } |
| 4146 | |
| 4147 | } |