package uk.ac.ebi.quickgo.annotation.service.comm.rest.geneproduct.transformer;

import uk.ac.ebi.quickgo.annotation.model.Annotation;
import uk.ac.ebi.quickgo.annotation.service.comm.rest.geneproduct.model.BasicGeneProduct;
import uk.ac.ebi.quickgo.rest.search.request.FilterRequest;
import uk.ac.ebi.quickgo.rest.search.request.converter.ConvertedFilter;
import uk.ac.ebi.quickgo.rest.search.results.transformer.AbstractValueInjector;

import java.util.List;

/**
 * This class is responsible for supplementing an {@link Annotation} instance, which contains
 * a gene product identifier, with a list of gene product synonyms, through the use of a RESTful service.
 * @author Tony Wardell
 * Date: 23/06/2017
 * Time: 14:56
 * Created with IntelliJ IDEA.
 */
public class GeneProductNameInjector extends AbstractValueInjector<BasicGeneProduct, Annotation> {

    static final String GENE_PRODUCT_ID = "geneProductId";
    static final String GENE_PRODUCT_NAME= "name";

    @Override
    public String getId() {
        return GENE_PRODUCT_NAME;
    }

    @Override
    public FilterRequest buildFilterRequest(Annotation annotation) {
        return FilterRequest.newBuilder()
                            .addProperty(getId())
                            .addProperty(GENE_PRODUCT_ID, annotation.geneProductId.split(":")[1])
                            .build();
    }

    @Override
    public void injectValueFromResponse(ConvertedFilter<BasicGeneProduct> convertedRequest, Annotation annotation) {
        BasicGeneProduct response = convertedRequest.getConvertedValue();

        List<BasicGeneProduct.Result> results = response.getResults();
        if (!results.isEmpty()) {
            annotation.name = results.get(0).getName();
        }
    }
}

@@ -466,23 +466,9 @@
 %0A * 
-This class is r
+R
 espo
@@ -839,24 +839,32 @@
 ion%3E %7B%0A%0A    
+private 
 static final
@@ -947,16 +947,17 @@
 UCT_NAME
+ 
 = %22name%22

Change javadoc, make GENE_PRODUCT_ID private.