- RAML::JsonSchemaPtr properties = schema->getProperties();
- if (!properties || 0 == properties->getProperties().size())
- return nullptr;
-
- SimulatorResourceModelSP repSchema = std::make_shared<SimulatorResourceModel>();
- for (auto & propertyEntry : properties->getProperties())
- {
- std::string propName = propertyEntry.second->getName();
- if ("rt" == propName || "resourceType" == propName || "if" == propName
- || "p" == propName || "n" == propName || "id" == propName)
- continue;
-
- int valueType = propertyEntry.second->getValueType();
- switch (valueType)
- {
- case 0: // Integer
- {
- // Add the attribute with value
- repSchema->addAttribute(propertyEntry.second->getName(), propertyEntry.second->getValue<int>());
-
- // Set the range
- int min, max, multipleof;
- propertyEntry.second->getRange(min, max, multipleof);
- repSchema->setRange(propertyEntry.second->getName(), min, max);
- }
- break;
-
- case 1: // Double
- {
- // Add the attribute with value
- repSchema->addAttribute(propertyEntry.second->getName(), propertyEntry.second->getValue<double>());
-
- std::vector<SimulatorResourceModel::Attribute::ValueVariant> propValues =
- propertyEntry.second->getAllowedValues();
-
- // TODO: Use RAML function once available
- if (0 < propertyEntry.second->getAllowedValuesSize())
- {
- std::vector<double> allowedValues;
- for (auto & propValue : propValues)
- {
- double value = boost::lexical_cast<double> (propValue);
- allowedValues.push_back(value);
- }
- repSchema->setAllowedValues(propertyEntry.second->getName(), allowedValues);
- }
- }
- break;
-
- case 2: // Boolean
- {
- // Add the attribute with value
- repSchema->addAttribute(propertyEntry.second->getName(), propertyEntry.second->getValue<bool>());
- }
- break;
-
- case 3: // String
- {
- // Add the attribute with value
- repSchema->addAttribute(propertyEntry.second->getName(),
- propertyEntry.second->getValue<std::string>());
-
- std::vector<SimulatorResourceModel::Attribute::ValueVariant> propValues =
- propertyEntry.second->getAllowedValues();
-
- // TODO: Use RAML function once available
- if (0 < propertyEntry.second->getAllowedValuesSize())
- {
- std::vector<std::string> allowedValues;
- for (auto & propValue : propValues)
- {
- std::string value = boost::lexical_cast<std::string> (propValue);
- allowedValues.push_back(value);
- }
- repSchema->setAllowedValues(propertyEntry.second->getName(), allowedValues);
- }
- }
- break;
- }
- }
-
- return repSchema;
-}
-
-RequestType RequestModelBuilder::getRequestType(RAML::ActionType actionType)
-{
- switch (actionType)
- {
- case RAML::ActionType::GET:
- return RequestType::RQ_TYPE_GET;
- case RAML::ActionType::PUT:
- return RequestType::RQ_TYPE_PUT;
- case RAML::ActionType::POST:
- return RequestType::RQ_TYPE_POST;
- case RAML::ActionType::DELETE:
- return RequestType::RQ_TYPE_DELETE;
- }