Commit 53974549 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

DrugView class removed

parent f6f42957
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
......@@ -9,6 +10,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.model.map.MiriamData;
/**
......@@ -309,4 +311,22 @@ public class Drug implements Serializable, TargettingStructure {
this.approved = approved;
}
/**
* Comparator of the objects by their name.
*
* @author Piotr Gawron
*
*/
public static class NameComparator implements Comparator<Drug> {
/**
* Default string comparator.
*/
private StringComparator stringComparator = new StringComparator();
@Override
public int compare(Drug arg0, Drug arg1) {
return stringComparator.compare(arg0.getName(), arg1.getName());
}
}
}
\ No newline at end of file
......@@ -25,7 +25,6 @@ import lcsb.mapviewer.services.interfaces.IUserService;
import lcsb.mapviewer.services.search.ElementMatcher;
import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType;
import lcsb.mapviewer.services.search.db.DbSearchCriteria;
import lcsb.mapviewer.services.search.db.drug.DrugView;
import lcsb.mapviewer.services.search.db.drug.IDrugService;
import lcsb.mapviewer.services.view.AuthenticationToken;
......
......@@ -299,7 +299,7 @@ public class DrugService implements IDrugService {
removeUnknownOrganisms(drug, searchCriteria.getOrganisms());
}
Collections.sort(drugList, new DrugView.NameComparator());
Collections.sort(drugList, new Drug.NameComparator());
return drugList;
}
......
package lcsb.mapviewer.services.search.db.drug;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.apache.log4j.Logger;
import lcsb.mapviewer.annotation.data.Drug;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.services.search.ISearchResultView;
import lcsb.mapviewer.services.search.db.TargetView;
import lcsb.mapviewer.services.view.AbstractView;
import lcsb.mapviewer.services.view.AnnotationView;
/**
* Data of the drug from external database to be visualized in the client side.
*
* @author Piotr Gawron
*
*/
public class DrugView extends AbstractView<Drug> implements Serializable, ISearchResultView {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(DrugView.class);
/**
* Comparator of the objects by their name.
*
* @author Piotr Gawron
*
*/
public static class NameComparator implements Comparator<Drug> {
/**
* Default string comparator.
*/
private StringComparator stringComparator = new StringComparator();
@Override
public int compare(Drug arg0, Drug arg1) {
return stringComparator.compare(arg0.getName(), arg1.getName());
}
}
/**
* Is the drug selected by the client or not.
*/
private boolean selected = false;
/**
* Name of the drug.
*/
private String name;
/**
* List of links to extenral databases.
*/
private List<AnnotationView> drugLinks = new ArrayList<>();
/**
* List of targets for the drug.
*/
private List<TargetView> targetRows = new ArrayList<>();
/**
* Description of the drug.
*/
private String description;
/**
* Status of blood brain barries for the drug.
*/
private String bloodBrainBarrier = "N/A";
/**
* Known brand names.
*/
private List<String> brandNames = new ArrayList<>();
/**
* Known synonyms.
*/
private List<String> synonyms = new ArrayList<>();
/**
* Constructor that initialize the data with information from the parameter
* object.
*
* @param drug
* original Drug from which the data will be initialized
*/
protected DrugView(Drug drug) {
// drug is not db entity so don't pass it to super constructor
super(null);
}
/**
* Default constructor. Should be used only for deserialization.
*/
protected DrugView() {
}
/**
* Default constructor that creates a copy.
*
* @param original
* origianl object that should be copied
*/
public DrugView(DrugView original) {
super(null);
selected = original.isSelected();
name = original.getName();
drugLinks.addAll(original.getDrugLinks());
targetRows.addAll(original.getTargetRows());
description = original.getDescription();
bloodBrainBarrier = original.getBloodBrainBarrier();
brandNames.addAll(original.getBrandNames());
synonyms.addAll(original.getSynonyms());
}
/**
* @return the drugLinks
* @see #drugLinks
*/
public List<AnnotationView> getDrugLinks() {
return drugLinks;
}
/**
* @param drugLinks
* the drugLinks to set
* @see #drugLinks
*/
public void setDrugLinks(List<AnnotationView> drugLinks) {
this.drugLinks = drugLinks;
}
/**
* @return the selected
* @see #selected
*/
public boolean isSelected() {
return selected;
}
/**
* @param selected
* the selected to set
* @see #selected
*/
public void setSelected(boolean selected) {
this.selected = selected;
}
/**
* @return the targetRows
* @see #targetRows
*/
public List<TargetView> getTargetRows() {
return targetRows;
}
/**
* @param targetRows
* the targetRows to set
* @see #targetRows
*/
public void setTargetRows(List<TargetView> targetRows) {
this.targetRows = targetRows;
}
/**
* @return the name
* @see #name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
* @see #name
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
* @see #description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
* @see #description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the bloodBrainBarrier
* @see #bloodBrainBarrier
*/
public String getBloodBrainBarrier() {
return bloodBrainBarrier;
}
/**
* @param bloodBrainBarrier
* the bloodBrainBarrier to set
* @see #bloodBrainBarrier
*/
public void setBloodBrainBarrier(String bloodBrainBarrier) {
this.bloodBrainBarrier = bloodBrainBarrier;
}
/**
* @return the brandNames
* @see #brandNames
*/
public List<String> getBrandNames() {
return brandNames;
}
/**
* @param brandNames
* the brandNames to set
* @see #brandNames
*/
public void setBrandNames(List<String> brandNames) {
this.brandNames = brandNames;
}
/**
* @return the synonyms
* @see #synonyms
*/
public List<String> getSynonyms() {
return synonyms;
}
/**
* @param synonyms
* the synonyms to set
* @see #synonyms
*/
public void setSynonyms(List<String> synonyms) {
this.synonyms = synonyms;
}
/**
* Adds a synonym to {@link #synonyms}.
*
* @param synonym
* synonym to add
*/
public void addSynonym(String synonym) {
synonyms.add(synonym);
}
/**
* Adds a brand name to {@link #brandNames}.
*
* @param brandName
* brand name to add
*/
public void addBrandName(String brandName) {
brandNames.add(brandName);
}
/**
* Adds object to {@link #drugLinks}.
*
* @param view
* object to add
*/
public void addDrugLink(AnnotationView view) {
drugLinks.add(view);
}
/**
* Adds objects to {@link #brandNames}.
*
* @param brandNames2
* objects to add
*/
public void addBrandNames(List<String> brandNames2) {
brandNames.addAll(brandNames2);
}
/**
* Adds objects to {@link #synonyms}.
*
* @param synonyms2
* object to add
*/
public void addSynonyms(List<String> synonyms2) {
synonyms.addAll(synonyms2);
}
/**
* Adds object to {@link #targetRows}.
*
* @param row
* object to add
*/
public void addTargetRow(TargetView row) {
targetRows.add(row);
}
@Override
public String getUniqueId() {
return name;
}
@Override
public void setUniqueId(String uniqueId) {
setName(uniqueId);
}
}
......@@ -6,7 +6,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ DrugServiceTest.class, //
DrugViewTest.class,//
})
public class AllSearchDrugTests {
......
package lcsb.mapviewer.services.search.db.drug;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import lcsb.mapviewer.services.search.db.drug.DrugView;
public class DrugViewTest {
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testSerialization() {
try {
SerializationUtils.serialize(new DrugView());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
......@@ -4,8 +4,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.services.search.db.drug.DrugViewTest;
@RunWith(Suite.class)
@SuiteClasses({ AnnotationViewFactoryTest.class, //
AnnotationViewTest.class, //
......@@ -16,7 +14,6 @@ import lcsb.mapviewer.services.search.db.drug.DrugViewTest;
DataMiningSetViewTest.class, //
DataMiningViewFactoryTest.class, //
DataMiningViewTest.class, //
DrugViewTest.class, //
FrameworkVersionViewTest.class, //
LayoutViewFactoryTest.class, //
LayoutViewTest.class, //
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment