Skip to content

Commit

Permalink
Issue #731 Metabolic pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
okolesn committed Jan 26, 2022
1 parent 6609b9e commit 03da9b5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
36 changes: 36 additions & 0 deletions server/ngb-cli/src/main/java/com/epam/ngb/cli/entity/Page.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* MIT License
*
* Copyright (c) 2022 EPAM Systems
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.epam.ngb.cli.entity;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
public class Page<T> {
List<T> items;
long totalCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.epam.ngb.cli.app.ApplicationOptions;
import com.epam.ngb.cli.constants.MessageConstants;
import com.epam.ngb.cli.entity.Page;
import com.epam.ngb.cli.entity.ResponseResult;
import com.epam.ngb.cli.entity.pathway.Pathway;
import com.epam.ngb.cli.exception.ApplicationException;
Expand Down Expand Up @@ -63,24 +64,24 @@ public void parseAndVerifyArguments(List<String> arguments, ApplicationOptions o
@Override public int runCommand() {
final HttpRequestBase request = getRequest(getRequestUrl());
final String result = RequestManager.executeRequest(request);
final ResponseResult<List<Pathway>> responseResult;
final ResponseResult<Page<Pathway>> responseResult;
try {
responseResult = getMapper().readValue(result,
getMapper().getTypeFactory().constructParametrizedType(
ResponseResult.class, ResponseResult.class,
getMapper().getTypeFactory().constructParametrizedType(
List.class, List.class, Pathway.class)));
getMapper().getTypeFactory()
.constructParametrizedType(Page.class, Page.class, Pathway.class)));
} catch (IOException e) {
throw new ApplicationException(e.getMessage(), e);
}
if (!SUCCESS_STATUS.equals(responseResult.getStatus())) {
throw new ApplicationException(responseResult.getMessage());
}
if (responseResult.getPayload() == null ||
responseResult.getPayload().isEmpty()) {
responseResult.getPayload().getItems().isEmpty()) {
log.info("No metabolic pathways registered on the server.");
} else {
List<Pathway> pathways = responseResult.getPayload();
List<Pathway> pathways = responseResult.getPayload().getItems();
AbstractResultPrinter printer = AbstractResultPrinter
.getPrinter(printTable, pathways.get(0).getFormatString(pathways));
printer.printHeader(pathways.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.epam.ngb.cli.app.ApplicationOptions;
import com.epam.ngb.cli.constants.MessageConstants;
import com.epam.ngb.cli.entity.ResponseResult;
import com.epam.ngb.cli.entity.lineage.LineageTree;
import com.epam.ngb.cli.entity.pathway.Pathway;
import com.epam.ngb.cli.entity.pathway.PathwayRegistrationRequest;
import com.epam.ngb.cli.exception.ApplicationException;
Expand Down

0 comments on commit 03da9b5

Please sign in to comment.