コード例 #1
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 private EntityCategory getCategoryNode(Object node) {
   int typeIdx = d_domain.getCategories().indexOf(node);
   if (typeIdx >= 0) {
     return d_domain.getCategories().get(typeIdx);
   }
   return null;
 }
コード例 #2
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
  public DomainTreeModel(Domain domain) {
    d_domain = domain;

    for (EntityCategory c : d_domain.getCategories()) {
      d_domain.getCategoryContents(c).addListDataListener(new CategoryListener(c));
    }

    d_listeners = new ArrayList<TreeModelListener>();
  }
コード例 #3
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 public boolean isLeaf(Object node) {
   if (node instanceof Entity) {
     EntityCategory category = d_domain.getCategory(((Entity) node));
     if (category != null) {
       return d_domain.getCategoryContents(category).contains(node);
     }
   }
   return false;
 }
コード例 #4
0
  @Test
  public void testConvertNetworkMetaAnalysis()
      throws Exception, InstantiationException, InvocationTargetException, NoSuchMethodException {
    Domain domain = new DomainImpl();
    ExampleData.initDefaultData(domain);
    String name = "CGI network meta-analysis";
    MetaAnalysisWithStudies ma = d_jaxbConverterTest.buildNetworkMetaAnalysis(name);

    List<Study> studies = new ArrayList<Study>();
    for (org.drugis.addis.entities.data.Study study : ma.d_studies) {
      Study studyEnt = JAXBConvertor.convertStudy(study, domain);
      domain.getStudies().add(studyEnt);
      studies.add(studyEnt);
    }

    TreatmentDefinition combi =
        TreatmentDefinition.createTrivial(
            Arrays.asList(ExampleData.buildDrugFluoxetine(), ExampleData.buildDrugSertraline()));
    TreatmentDefinition parox =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine());
    TreatmentDefinition sertr =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugSertraline());
    SortedSet<TreatmentDefinition> alternatives = new TreeSet<TreatmentDefinition>();
    alternatives.add(combi);
    alternatives.add(parox);
    alternatives.add(sertr);
    Map<Study, Map<TreatmentDefinition, Arm>> armMap =
        new HashMap<Study, Map<TreatmentDefinition, Arm>>();
    Map<TreatmentDefinition, Arm> study1map = new HashMap<TreatmentDefinition, Arm>();
    study1map.put(combi, studies.get(0).getArms().get(0));
    study1map.put(sertr, studies.get(0).getArms().get(1));
    armMap.put(studies.get(0), study1map);
    Map<TreatmentDefinition, Arm> study2map = new HashMap<TreatmentDefinition, Arm>();
    study2map.put(parox, studies.get(1).getArms().get(0));
    study2map.put(sertr, studies.get(1).getArms().get(1));
    armMap.put(studies.get(1), study2map);
    Map<TreatmentDefinition, Arm> study3map = new HashMap<TreatmentDefinition, Arm>();
    study3map.put(sertr, studies.get(2).getArms().get(0));
    study3map.put(parox, studies.get(2).getArms().get(1));
    study3map.put(combi, studies.get(2).getArms().get(2));
    armMap.put(studies.get(2), study3map);

    Collections.sort(
        studies); // So the reading *by definition* puts the studies in their natural order
    NetworkMetaAnalysis expected =
        new NetworkMetaAnalysis(
            name,
            ExampleData.buildIndicationDepression(),
            ExampleData.buildEndpointCgi(),
            studies,
            alternatives,
            armMap);

    assertEntityEquals(expected, NetworkMetaAnalysisConverter.load(ma.d_nwma, domain));
    assertEquals(ma.d_nwma, NetworkMetaAnalysisConverter.save(expected));
  }
コード例 #5
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 public TreePath getPathTo(Object node) {
   if (d_root.equals(node)) {
     return new TreePath(new Object[] {d_root});
   } else if (d_domain.getCategories().contains(node)) {
     return new TreePath(new Object[] {d_root, node});
   } else if (isLeaf(node)) {
     return new TreePath(new Object[] {d_root, d_domain.getCategory(((Entity) node)), node});
   }
   return null;
 }
コード例 #6
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 public Object getChild(Object parent, int childIndex) {
   if (d_root.equals(parent) && childIndex >= 0 && childIndex < d_domain.getCategories().size()) {
     return d_domain.getCategories().get(childIndex);
   } else {
     for (EntityCategory cat : d_domain.getCategories()) {
       if (isCategoryRequest(cat, parent, childIndex)) {
         return d_domain.getCategoryContents(cat).get(childIndex);
       }
     }
   }
   return null;
 }
コード例 #7
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 public int getIndexOfChild(Object parent, Object child) {
   if (parent.equals(d_root)) {
     return d_domain.getCategories().indexOf(child);
   } else {
     ObservableList<? extends Entity> contents =
         d_domain.getCategoryContents(getCategoryNode(parent));
     if (contents != null) {
       return contents.indexOf(child);
     }
   }
   return -1;
 }
コード例 #8
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 public int getChildCount(Object parent) {
   if (d_root.equals(parent)) {
     return d_domain.getCategories().size();
   } else {
     ObservableList<? extends Entity> contents =
         d_domain.getCategoryContents(getCategoryNode(parent));
     if (contents != null) {
       return contents.size();
     }
   }
   return 0;
 }
コード例 #9
0
ファイル: AddUnitDialog.java プロジェクト: woutgg/addis
  @Override
  protected void commit() {
    if (d_domain.getUnits().contains(d_unit)) {
      JOptionPane.showMessageDialog(
          d_mainWindow,
          "An item with the name " + d_unit.getName() + " already exists in the domain.",
          "Couldn't add Unit",
          JOptionPane.ERROR_MESSAGE);
      return;
    }

    d_domain.getUnits().add(d_unit);
    setVisible(false);
    d_mainWindow.leftTreeFocus(d_unit);
    if (d_selectionModel != null) d_selectionModel.setValue(d_unit);
  }
コード例 #10
0
 @Override
 public ViewBuilder getCategoryViewBuilder(AddisWindow main, Domain domain) {
   StudyListPresentation studyListPM = new StudyListPresentation(domain.getStudies());
   TitledPanelBuilder view =
       new TitledPanelBuilder(new StudiesTablePanel(studyListPM, main), "Studies");
   return view;
 }
コード例 #11
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 private void fireTreeNodeInserted(EntityCategory category, int idx) {
   for (TreeModelListener l : d_listeners) {
     l.treeNodesInserted(
         new TreeModelEvent(
             this,
             new Object[] {d_root, category},
             new int[] {idx},
             new Object[] {d_domain.getCategoryContents(category).get(idx)}));
   }
 }
コード例 #12
0
ファイル: DomainTreeModel.java プロジェクト: DevFactory/addis
 private boolean isCategoryRequest(EntityCategory categoryNode, Object parent, int childIndex) {
   return categoryNode == parent
       && childIndex >= 0
       && childIndex < d_domain.getCategoryContents(categoryNode).size();
 }