Package view.menu

Source Code of view.menu.DecadeMenu

package view.menu;

import java.util.ArrayList;
import java.util.Collections;

import javax.swing.JMenu;

import model.array.tools.DecadeComparator;
import model.movie.Decade;
import model.query.OntologyQueryer;

import com.hp.hpl.jena.query.ResultSet;

import controller.DecadeController;

public class DecadeMenu extends JMenu {
  private static final long serialVersionUID = 8647053186534487432L;

  private ArrayList<Decade> decades;
  private DecadeController decadeController;
 
  public DecadeMenu(DecadeController controller) {
    super("Decades");
    decades = getDecades();
    decadeController = controller;
   
    for (Decade decade : decades)
      add(new DecadeItem(decade.getName(), decade.getUri(), decadeController));
  }

  private ArrayList<Decade> getDecades() {
    ArrayList<Decade> decades = new ArrayList<Decade>();
   
    String queryText =  "SELECT DISTINCT ?decade WHERE {" +
                "?decade rdfs:subClassOf h2mdb:Decade . " +
              "} ";
    ResultSet resultSet = OntologyQueryer.resultQuery(queryText);
    while(resultSet.hasNext()) {
      String uri = resultSet.next().get("decade").toString();
      if (uri.contains("http://h2mdb.no/") && !uri.contains("Decade"))
        decades.add(new Decade(uri, uri.replace("http://h2mdb.no/", "")));
    }
   
    Collections.sort(decades, new DecadeComparator());
    return decades;
  }
}
TOP

Related Classes of view.menu.DecadeMenu

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.