/** * Check if act as Restful show method * * @return true if act as Restful show method, false otherwise */ @Override public boolean isRestfulShow() { return "GET".equals(httpMethod) && isByIdPath(); }
public boolean isRelationPath() { return isParentChildPath() || isRelatedToManyPath(); }
/** * Check if act as Restful child via parent destroy method * * @return true if act as Restful child via parent destroy method, false otherwise */ public boolean isRestfulRelatedDestroy() { return "DELETE".equalsIgnoreCase(httpMethod) && isParentChildPath(); }
/** * Check if act as Restful destroy many children method * * @return true if act as Restful destroy many child items method, false otherwise */ public boolean isRestfulDestroyToMany() { return "DELETE".equalsIgnoreCase(httpMethod) && isRelatedToManyPath(); }
/** * Check if act as Restful bulk update method * * @return true if act as Restful bulk update method, false otherwise */ public boolean isRestfulBulkUpdate() { return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && !getHasPathParams(); }
private void populateRelations(AgCodegenOperation operation, AgCodegenOperation relation) { // if path looks like /xxx/:id/yyy/:tid or /xxx/:id/yyy's, stores corresponding relation only if (operation.isRelationPath()) { // copies queryParam's from parent operation to child relation relation.allParams = relation.queryParams = operation.queryParams; if (operation.bodyParam == null) { // In case of GET or DELETE operations final String[] path = operation.path.split("/"); if (path.length > 1 && (relation.bodyParam.paramName.equalsIgnoreCase(path[path.length - 1]) || relation.bodyParam.paramName.equalsIgnoreCase(path[path.length - 2]))) { operation.modelRelations.add(relation); } } else if (relation.baseName.equalsIgnoreCase(operation.bodyParam.baseType)) { operation.modelRelations.add(relation); } } else { operation.modelRelations.add(relation); } }
AgCodegenOperation newOperation = new AgCodegenOperation(operation); AgCodegenOperation relation = new AgCodegenOperation(); relation.returnType = relation.baseName = prop.complexType; relation.bodyParam = new CodegenParameter();
/** * Check if act as Restful index to retrieve child via parent method * * @return true if act as Restful index to child via parent, false otherwise */ public boolean isRestfulIndexRelated() { return "GET".equals(httpMethod) && isParentChildPath() ; }
/** * Check if act as Restful many children via parent create method * * @return true if act as Restful many children via parent create method, false otherwise */ public boolean isRestfulRelatedToManyCreate() { return "POST".equalsIgnoreCase(httpMethod) && isRelatedToManyPath() ; }
/** * Check if act as Restful destroy method * * @return true if act as Restful destroy method, false otherwise */ public boolean isRestfulDestroy() { return "DELETE".equalsIgnoreCase(httpMethod) && !isRelatedToManyPath() && !isParentChildPath(); }
/** * Check if act as Restful child via parent create method * * @return true if act as Restful child via parent create method, false otherwise */ public boolean isRestfulRelatedCreate() { return "POST".equalsIgnoreCase(httpMethod) && isParentChildPath() ; }
/** * Check if act as Restful index to retrieve many children method * * @return true if act as Restful index to many items method, false otherwise */ public boolean isRestfulIndexToMany() { return "GET".equals(httpMethod) && isRelatedToManyPath(); }
/** * Check if act as Restful child via parent update method * * @return true if act as Restful child via parent update method, false otherwise */ public boolean isRestfulRelatedUpdate() { return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isParentChildPath() ; }
/** * Check if act as Restful many children via parent update method * * @return true if act as Restful many children via parent update method, false otherwise */ public boolean isRestfulRelatedToManyUpdate() { return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isRelatedToManyPath() ; }