Mercurial > hg > LGServer
view src/main/java/de/mpiwg/web/FileCreator.java @ 0:7682c04c63a8
First commit of the source code!
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Tue, 10 Mar 2015 14:50:41 +0100 |
parents | |
children | 1f56cf4f80d4 |
line wrap: on
line source
package de.mpiwg.web; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.faces.event.ActionEvent; import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.icefaces.ace.event.TextChangeEvent; import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.utils.DBService; import de.mpiwg.gazetteer.utils.DataProvider; public class FileCreator extends AbstractBean{ private static Logger logger = Logger.getLogger(FileCreator.class); private DBSection section; private String label; private Long sectionId; private List<SelectItem> sectionSuggestion; public FileCreator(){ } public void reset(){ this.section = null; this.label = null; this.sectionId = null; this.sectionSuggestion = null; } public void listenerLoadSection(ActionEvent event){ if(sectionId != null){ try { this.section = DBService.getSectionWithContent(sectionId); } catch (SQLException e) { internalError(e); } } } public void listenerReset(ActionEvent event){ this.reset(); } public void changeSectionInput(TextChangeEvent event){ String input = event.getNewValue().toString(); this.sectionSuggestion = new ArrayList<SelectItem>(); try { List<String> list = DBService.suggestSectionId(input); System.out.println(list.size()); for(String s : list){ this.sectionSuggestion.add(new SelectItem(s)); } } catch (SQLException e) { internalError(e); } } public void listenerSaveNewFile(ActionEvent event){ if( section != null && StringUtils.isNotEmpty(section.getText()) && StringUtils.isNotEmpty(label)){ try { Long branchId = DataProvider.getInstance().saveNewFile( section.getText(), label, section.getId(), getSessionBean().getUser().getId()); addMsg("New branch created [id=" + branchId +"]"); } catch (Exception e) { internalError(e); } } } public DBSection getSection() { return section; } public void setSection(DBSection section) { this.section = section; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public Long getSectionId() { return sectionId; } public void setSectionId(Long sectionId) { this.sectionId = sectionId; } public List<SelectItem> getSectionSuggestion() { return sectionSuggestion; } public void setSectionSuggestion(List<SelectItem> sectionSuggestion) { this.sectionSuggestion = sectionSuggestion; } }