001package conexp.fx.gui.assistent;
002
003/*
004 * #%L
005 * Concept Explorer FX
006 * %%
007 * Copyright (C) 2010 - 2023 Francesco Kriegel
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as
011 * published by the Free Software Foundation, either version 3 of the
012 * License, or (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU General Public
020 * License along with this program.  If not, see
021 * <http://www.gnu.org/licenses/gpl-3.0.html>.
022 * #L%
023 */
024
025import java.util.List;
026import java.util.Optional;
027import java.util.stream.Collectors;
028
029//import org.semanticweb.owlapi.model.IRI;
030
031import com.google.common.collect.Collections2;
032
033import conexp.fx.gui.ConExpFX;
034//import conexp.fx.gui.assistent.ModelAssistent.Result;
035import conexp.fx.gui.dataset.RDFDataset;
036import javafx.application.Platform;
037import javafx.collections.FXCollections;
038import javafx.geometry.Insets;
039import javafx.scene.Node;
040import javafx.scene.control.ChoiceBox;
041import javafx.scene.control.Label;
042import javafx.scene.control.ListView;
043import javafx.scene.control.SelectionMode;
044import javafx.scene.layout.BorderPane;
045import javafx.scene.layout.HBox;
046import javafx.scene.layout.VBox;
047
048@Deprecated
049public class ModelAssistent {}
050//public class ModelAssistent extends Assistent<Result> {
051//
052//  public static class Result {
053//
054//    public List<IRI> selectedConceptNames;
055//    public List<IRI> selectedRoleNames;
056//    public IRI       selectedIsARoleName;
057//  }
058//
059//  private final RDFDataset dataset;
060//  final ListView<IRI>      conceptListView  = new ListView<IRI>();
061//  final ListView<IRI>      roleListView     = new ListView<IRI>();
062//  final ChoiceBox<IRI>     isaRoleChoiceBox = new ChoiceBox<IRI>();
063//
064//  public ModelAssistent(final RDFDataset dataset) {
065//    super(
066//        ConExpFX.instance.primaryStage,
067//        "Model Wizard",
068//        "Select Model Signature",
069//        "Extract a Model from a Dataset of RDF Triples (" + dataset.file.getName() + ")",
070//        null,
071//        r -> null);
072//    this.dataset = dataset;
073//    initialize();
074//    this.resultProperty.set(new Result());
075//    Platform.runLater(() -> {
076//      final Optional<IRI> typeRole =
077//          dataset.getRoles().parallelStream().filter(role -> role.toString().contains("type")).findAny();
078//      if (typeRole.isPresent())
079//        isaRoleChoiceBox.getSelectionModel().select(typeRole.get());
080//      else
081//        isaRoleChoiceBox.getSelectionModel().selectFirst();
082//    });
083//  }
084//
085//  public void showAndWait() {
086//    stage.showAndWait();
087//  }
088//
089//  @Override
090//  protected void onNext() {
091//    resultProperty.get().selectedConceptNames = conceptListView.getSelectionModel().getSelectedItems();
092//    resultProperty.get().selectedRoleNames = roleListView.getSelectionModel().getSelectedItems();
093//    resultProperty.get().selectedIsARoleName = isaRoleChoiceBox.getSelectionModel().getSelectedItem();
094//    dataset.createDLModel(
095//        conceptListView.getSelectionModel().getSelectedItems(),
096//        roleListView.getSelectionModel().getSelectedItems(),
097//        isaRoleChoiceBox.getSelectionModel().getSelectedItem());
098//  }
099//
100//  @Override
101//  protected Node createInitialNode() {
102//    final BorderPane pane = new BorderPane();
103//    pane.setPadding(new Insets(4));
104//    final Label isARoleLabel = new Label("IS-A Role Name");
105//    isARoleLabel.setPadding(new Insets(4));
106//    final Label conceptLabel = new Label("Concept Names");
107//    conceptLabel.setPadding(new Insets(4, 4, 1, 4));
108//    final Label roleLabel = new Label("Role Names");
109//    roleLabel.setPadding(new Insets(4, 4, 1, 4));
110//    conceptListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
111//    roleListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
112//    try {
113//      isaRoleChoiceBox.setItems(FXCollections.observableArrayList(dataset.getRoles()));
114//    } catch (NullPointerException e) {
115//      System.out.println();
116//    }
117//    final HBox rbox = new HBox(isARoleLabel, isaRoleChoiceBox);
118//    final VBox vbox = new VBox(rbox, conceptLabel, conceptListView, roleLabel, roleListView);
119//    pane.setCenter(vbox);
120//    isaRoleChoiceBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
121//      final List<IRI> concepts = dataset
122//          .getTriples()
123//          .parallelStream()
124//          .filter(triple -> IRI.create(triple.getPredicate().stringValue()).equals(newValue))
125//          .map(triple -> IRI.create(triple.getObject().stringValue()))
126//          .distinct()
127//          .sorted()
128//          .collect(Collectors.toList());
129//      conceptListView.setItems(FXCollections.observableArrayList(concepts));
130//      roleListView.setItems(
131//          FXCollections.observableArrayList(Collections2.filter(dataset.getRoles(), role -> !role.equals(newValue))));
132//      conceptListView.getSelectionModel().selectAll();
133//      roleListView.getSelectionModel().selectAll();
134//    });
135//    return pane;
136//  }
137//
138//  @Override
139//  protected void createPages() {}
140//
141//}