| 1 | |
package br.mia.test.view; |
| 2 | |
|
| 3 | |
import java.beans.XMLEncoder; |
| 4 | |
import java.io.BufferedOutputStream; |
| 5 | |
import java.io.FileOutputStream; |
| 6 | |
import java.io.IOException; |
| 7 | |
import java.sql.SQLException; |
| 8 | |
import java.util.List; |
| 9 | |
|
| 10 | |
import javax.swing.JFileChooser; |
| 11 | |
import javax.swing.JFrame; |
| 12 | |
|
| 13 | |
import br.mia.test.model.CasoUso; |
| 14 | |
import br.mia.test.model.dao.DAOUseCase; |
| 15 | |
import br.mia.test.util.Util; |
| 16 | |
|
| 17 | |
public class AllXMLExport extends JFrame { |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
private static final long serialVersionUID = 1L; |
| 23 | |
|
| 24 | |
|
| 25 | 0 | public AllXMLExport(List<CasoUso> list) throws IOException, |
| 26 | 0 | InstantiationException, IllegalAccessException, |
| 27 | |
ClassNotFoundException, SQLException { |
| 28 | |
|
| 29 | 0 | JFileChooser jFileChooser1 = new JFileChooser(); |
| 30 | 0 | jFileChooser1.setApproveButtonText("Selecionar"); |
| 31 | 0 | jFileChooser1.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 32 | 0 | int returnVal = jFileChooser1.showDialog(this, null); |
| 33 | 0 | if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 34 | 0 | |
| 35 | 0 | String diretorio = jFileChooser1.getSelectedFile() |
| 36 | 0 | .getPath(); |
| 37 | 0 | |
| 38 | |
|
| 39 | 0 | for (Object object : list) { |
| 40 | 0 | CasoUso useCase = (CasoUso) object; |
| 41 | 0 | |
| 42 | 0 | Util.recarga(useCase); |
| 43 | 0 | |
| 44 | 0 | DAOUseCase dao = new DAOUseCase(); |
| 45 | 0 | |
| 46 | 0 | useCase = dao.selectId(useCase.getId()); |
| 47 | 0 | |
| 48 | 0 | String fileName = diretorio + System.getProperties().getProperty("file.separator") + useCase.getName() + ".xml"; |
| 49 | 0 | |
| 50 | 0 | XMLEncoder xmlEncoder = new XMLEncoder( |
| 51 | 0 | new BufferedOutputStream(new FileOutputStream(fileName))); |
| 52 | 0 | |
| 53 | 0 | xmlEncoder.writeObject(useCase); |
| 54 | 0 | |
| 55 | 0 | xmlEncoder.close(); |
| 56 | 0 | |
| 57 | |
} |
| 58 | |
} |
| 59 | |
|
| 60 | 0 | } |
| 61 | 0 | |
| 62 | |
} |