functions.RESTOperation.ext Maven / Gradle / Ivy
extension java::GeneratorCommons;
extension functions::BeanParam;
extension functions::RESTResource;
cached boolean isRESTOperation(uml::Element element):
element.isStereotypeApplied("RESTOperation");
cached JMM::RESTOperation asRESTOperation(uml::Element element):
(JMM::RESTOperation) element;
cached String getFullPath(JMM::RESTOperation operation):
if operation.owner.isRESTResource()
then operation.getFullPath(operation.owner.asRESTResource())
else operation.getFullPath(null);
cached String getFullPath(JMM::RESTOperation operation, JMM::RESTResource restResource):
if operation.getRESTOperationPath(restResource).length > 0
then restResource.getRESTREsourcePath() + operation.getRESTOperationPath(restResource) + " " + operation.httpMethods
//then operation.owner.asRESTResource().path + "XXX"
else ((JMM::RESTResource) operation.owner).path + " " + operation.httpMethods;
private cached String getRESTREsourcePath(JMM::RESTResource restResource):
if restResource != null && restResource.path.length > 0
then restResource.path + "/"
else "/";
cached String getRESTOperationPath(JMM::RESTOperation operation):
if operation.owner.isRESTResource()
then operation.getRESTOperationPath(operation.owner.asRESTResource())
else operation.getRESTOperationPath(null);
cached String getRESTOperationPath(JMM::RESTOperation operation, JMM::RESTResource restResource):
if restResource == null
then operation.path
else
if operation.path.length > 0
then restResource.getRESTOperationPathPrefix() + operation.path
else restResource.getRESTOperationPathPrefix();
private String getRESTOperationPathPrefix(JMM::RESTResource restResource):
if restResource.operationPathPrefix.length > 0
then restResource.operationPathPrefix
else "";
cached boolean hasBeanParamsForRESTOperation(JMM::RESTOperation operation):
operation.getBeanParamsForRESTOperation().isEmpty == false;
cached List[JMM::BeanParam] getBeanParamsForRESTOperation(JMM::RESTOperation operation):
operation.ownedParameter.select(e|e.isParameterBeanParam()).parameterAsBeanParam();