public MLModel getModelInfo(Long modelId) { MLModel modelInfo = new MLModel(); modelInfo.setId(modelId); MLModel storedModelInfo = this.storageManager.get(modelInfo.getStorableKey()); if (storedModelInfo == null) { throw EntityNotFoundException.byId(modelId.toString()); } return storedModelInfo; }
public MLModel removeModelInfo(Long modelId) { MLModel modelInfo = new MLModel(); modelInfo.setId(modelId); MLModel removedModelInfo = this.storageManager.remove(modelInfo.getStorableKey()); if (removedModelInfo == null) { throw EntityNotFoundException.byId(modelId.toString()); } return removedModelInfo; }
/** * <p> * Gets all the entities tagged with the given tag id. This also recursively gets * all the entities belonging to any child tags of the given tag. The child tags itself * are not included in the result. * </p> * <b>GET /api/v1/catalog/tags/1/entities</b> * <pre> * { * "entities":[{ * "id":12, * "namespace":"tag" * }] * } * </pre> * * @param tagId the tag id * @return the response */ @GET @Path("/tags/{id}/entities") @Timed @UnitOfWork public Response getTaggedEntities(@PathParam("id") Long tagId) { List<TaggedEntity> result = tagService.getEntities(tagId, true); if (result != null) { return WSUtils.respondEntities(result, OK); } throw EntityNotFoundException.byId(tagId.toString()); }
/** * <p> * Tags the entity with the given tag. For example, * </p> * <b>POST /api/v1/catalog/tags/:TAG_ID/entities/:NAME_SPACE/:ENTITY_ID</b> * <i>Sample success response: </i> * <pre> * { * "responseMessage": "Success", * } * </pre> * * @param tagId * @param namespace * @param entityId * @return */ @POST @Path("/tags/{id}/entities/{namespace}/{entity-id}") @Timed @UnitOfWork public Response addTagForEntity(@PathParam("id") Long tagId, @PathParam("namespace") String namespace, @PathParam("entity-id") Long entityId) { Tag tag = tagService.getTag(tagId); if(tag != null) { tagService.addTagsForStorable(new TaggedEntity(namespace, entityId), Collections.singletonList(tag)); return WSUtils.respondEntity(SUCCESS_MESSAGE_ENTITY, CREATED); } throw EntityNotFoundException.byId(tagId.toString()); }
/** * <p> * Removes the given tag from the entity. * </p> * <b>DELETE /api/v1/catalog/tags/:TAG_ID/entities/:NAME_SPACE/:ENTITY_ID</b> * <pre> * { * "responseMessage": "Success", * } * </pre> * <p> * * @param tagId * @param namespace * @param entityId * @return */ @DELETE @Path("/tags/{id}/entities/{namespace}/{entity-id}") @Timed @UnitOfWork public Response removeTagFromEntity(@PathParam("id") Long tagId, @PathParam("namespace") String namespace, @PathParam("entity-id") Long entityId) { Tag tag = tagService.getTag(tagId); if(tag !=null ) { tagService.removeTagsFromStorable(new TaggedEntity(namespace, entityId), Collections.singletonList(tag)); return WSUtils.respondEntity(SUCCESS_MESSAGE_ENTITY, CREATED); } throw EntityNotFoundException.byId(tagId.toString()); }
/** * <p> * Gets a specific tag by Id. For example, * </p> * <b>GET /api/v1/catalog/tags/1</b> * <pre> * { * "id": 2, * "name": "device", * "description": "device tag", * "timestamp": 1481673156548, * "tagIds": [] * } * </pre> * * @param tagId the tag id * @return the response */ @GET @Path("/tags/{id}") @Timed @UnitOfWork public Response getTagById(@PathParam("id") Long tagId) { Tag result = tagService.getTag(tagId); if (result != null) { return WSUtils.respondEntity(makeTagDto(result), OK); } throw EntityNotFoundException.byId(tagId.toString()); }
throw EntityNotFoundException.byId(entityId.toString());
throw EntityNotFoundException.byId(removedTag.toString());