Esempio n. 1
0
  public static void upPublication(Publication p, Section s) throws MappingException {
    SectionPublication currentSP = SectionPublication.findSectionPublication(s, p);
    int currentIndex = currentSP.getIndex();
    SectionPublication nextSP = SectionPublication.findNextSectionPublication(s, currentIndex);
    if (nextSP != null) {
      int nextIndex = nextSP.getIndex();
      nextSP.setIndex(currentIndex);
      currentSP.setIndex(nextIndex);
    }

    /*
    try {
        int currentIndex = Integer.parseInt(p.getMetaData("index_"
                + s.getId())
                + "");
        int newIndex = currentIndex + 1;
        Vector publications = s.listPublications();
        if (newIndex > publications.size()) {
            newIndex = publications.size();
        } else {
            for (int i = 0; i < publications.size(); i++) {
                if (newIndex == Integer
                        .parseInt(((Publication) publications.get(i))
                                .getMetaData("index_" + s.getId())
                                + "")) {
                    Publication pac = (Publication) publications.get(i);
                    pac.setMetaData("index_" + s.getId(), (Integer
                            .parseInt(pac.getMetaData("index_" + s.getId())
                                    + "") - 1)
                            + "");
                }
            }

        }
        p.setMetaData("index_" + s.getId(), newIndex + "");
    } catch (Exception e) {
        //e.printStackTrace();
        org.nextime.ion.framework.logger.Logger.getInstance().error(
                e.getMessage(), PublicationSorter.class,e);
    } */

  }