Search in sources :

Example 1 with ContentDTO

use of com.tomasio.projects.trainning.dto.ContentDTO in project trainning by fernandotomasio.

the class MainPlanejamentoController method detailItemPlanejamento.

@RequestMapping("/detail_item_planejamento")
@ResponseBody
public Map detailItemPlanejamento(Model model, WebRequest request) {
    String itemPlanejamentoIdParam = request.getParameter("itemPlanejamentoId");
    Map result = new HashMap();
    Long itemPlanejamentoId = Long.parseLong(itemPlanejamentoIdParam);
    ItemPlanejamentoDTO itemPlanejamento = planningService.findItemPlanejamento(itemPlanejamentoId);
    ContentDTO[] documentos = ecmService.findAllContentByUUID("bb5191f8-f3ed-4584-b292-34f16c61382c");
    result.put("codigo", itemPlanejamento.getCurso().getCodigo());
    // Aqui falta percorrer os documentos e comparar com o código pra devolver o UID PUD !
    String cursoCodigo = itemPlanejamento.getCurso().getCodigo() + ".pdf";
    for (ContentDTO documento : documentos) {
        if (documento.getName().equals(cursoCodigo)) {
            result.put("uid", documento.getUid());
        }
    }
    result.put("descricao", itemPlanejamento.getCurso().getDescricao());
    result.put("id", itemPlanejamento.getId());
    return result;
}
Also used : ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) StripItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with ContentDTO

use of com.tomasio.projects.trainning.dto.ContentDTO in project trainning by fernandotomasio.

the class ImportTurmasImplEfetivasFromTabelao method recuperarDocumentos.

private void recuperarDocumentos(String codCurso, String numeroTurma, TurmaEfetiva turmaCriada, Connection conn) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    ContentDAO contentDAO = new AlfrescoContentDAO();
    TurmaDAO turmaDAO = new HibernateTurmaDAO();
    String documentsRoot = "SGC/Documentos de Treinamentos/testes";
    String oldFolderName = "D-CTP/Documentos de Treinamentos/2013/" + codCurso + "-" + numeroTurma;
    String newFolderName = df.format(turmaCriada.getExercicio()) + "_" + turmaCriada.getCurso().getCodigo() + "_" + turmaCriada.getNumeroTurma() + "_" + turmaCriada.getId();
    try {
        WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
        boolean existsOldFolder = contentExistsByPath(oldFolderName);
        if (existsOldFolder) {
            WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
            FolderDTO folder = new FolderDTO();
            folder.setName(newFolderName);
            String folderId = contentDAO.createFolder(folder, documentsRoot);
            turmaCriada.setFolderId(folderId);
            turmaDAO.update(turmaCriada);
            WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
            ContentDTO[] contents = findAllContentByPath(oldFolderName);
            for (ContentDTO content : contents) {
                WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
                DocumentDTO document = findDocumentByUUID(content.getUid());
                document.setMimeType("application/pdf");
                WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
                contentDAO.createDocumentWithUUIDParent(document, folderId);
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : ParseException(java.text.ParseException) RemoteException(java.rmi.RemoteException) DAOException(com.tomasio.projects.trainning.exception.DAOException) ContentDAO(com.tomasio.projects.trainning.dao.ContentDAO) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) FolderDTO(com.tomasio.projects.trainning.dto.FolderDTO) HibernateTurmaDAO(com.tomasio.projects.trainning.dao.HibernateTurmaDAO) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) HibernateTurmaDAO(com.tomasio.projects.trainning.dao.HibernateTurmaDAO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with ContentDTO

use of com.tomasio.projects.trainning.dto.ContentDTO in project trainning by fernandotomasio.

the class AlfrescoContentDAO method findAllContentByPath.

@Override
public ContentDTO[] findAllContentByPath(String path) {
    ContentDTO[] contents = null;
    try {
        AuthenticationUtils.startSession(USERNAME, PASSWORD);
        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
        // Get a reference to the space we have named
        Reference reference = new Reference(STORE, null, encodePath(path));
        Predicate predicate = new Predicate(new Reference[] { reference }, null, null);
        Node[] nodes = repositoryService.get(predicate);
        // Create a query object, looking for all items with alfresco in the
        // name of text
        Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PARENT:\"workspace://SpacesStore/" + nodes[0].getReference().getUuid() + "\"");
        // Execute the query
        QueryResult queryResult = repositoryService.query(STORE, query, false);
        // Display the results
        ResultSet resultSet = queryResult.getResultSet();
        ResultSetRow[] rows = resultSet.getRows();
        if (rows != null) {
            contents = new ContentDTO[rows.length];
            // Get the infomation from the result set
            for (int i = 0; i < rows.length; i++) {
                ResultSetRow row = (ResultSetRow) rows[i];
                String nodeId = row.getNode().getId();
                ContentDTO content = new ContentDTO();
                content.setUid(nodeId);
                for (NamedValue namedValue : row.getColumns()) {
                    if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true) {
                    // contentResult.setCreateDate(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true) {
                        content.setName(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true) {
                        content.setDescription(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_TITLE) == true) {
                        content.setTitle(namedValue.getValue());
                    }
                }
                contents[i] = content;
            // results.add(contentResult);
            }
        }
    } catch (AuthenticationFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
    } catch (RepositoryFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
    } catch (RemoteException e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
    } finally {
        // End the session
        AuthenticationUtils.endSession();
    }
    return contents;
}
Also used : Query(org.alfresco.webservice.types.Query) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) ResultSetRow(org.alfresco.webservice.types.ResultSetRow) NamedValue(org.alfresco.webservice.types.NamedValue) Predicate(org.alfresco.webservice.types.Predicate) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) QueryResult(org.alfresco.webservice.repository.QueryResult) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) ResultSet(org.alfresco.webservice.types.ResultSet) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException)

Example 4 with ContentDTO

use of com.tomasio.projects.trainning.dto.ContentDTO in project trainning by fernandotomasio.

the class AlfrescoContentDAO method findAllContentByUUID.

@Override
public ContentDTO[] findAllContentByUUID(String uuid) {
    ContentDTO[] contents = null;
    try {
        AuthenticationUtils.startSession(USERNAME, PASSWORD);
        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
        Reference node = new Reference();
        node.setStore(STORE);
        node.setUuid(uuid);
        Node[] nodes = null;
        nodes = repositoryService.get(new Predicate(new Reference[] { node }, STORE, null));
        // Create a query object, looking for all items with alfresco in the
        // name of text
        Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PARENT:\"workspace://SpacesStore/" + nodes[0].getReference().getUuid() + "\"");
        // Execute the query
        QueryResult queryResult = repositoryService.query(STORE, query, false);
        // Display the results
        ResultSet resultSet = queryResult.getResultSet();
        ResultSetRow[] rows = resultSet.getRows();
        if (rows != null) {
            contents = new ContentDTO[rows.length];
            // Get the infomation from the result set
            for (int i = 0; i < rows.length; i++) {
                ResultSetRow row = (ResultSetRow) rows[i];
                String nodeId = row.getNode().getId();
                ContentDTO content = new ContentDTO();
                content.setUid(nodeId);
                for (NamedValue namedValue : row.getColumns()) {
                    if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true) {
                    // contentResult.setCreateDate(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true) {
                        content.setName(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true) {
                        content.setDescription(namedValue.getValue());
                    } else if (namedValue.getName().endsWith(Constants.PROP_TITLE) == true) {
                        content.setTitle(namedValue.getValue());
                    }
                }
                contents[i] = content;
            // results.add(contentResult);
            }
        }
    } catch (AuthenticationFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
    } catch (RepositoryFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
    } catch (RemoteException e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
    } finally {
        // End the session
        AuthenticationUtils.endSession();
    }
    return contents;
}
Also used : Query(org.alfresco.webservice.types.Query) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) ResultSetRow(org.alfresco.webservice.types.ResultSetRow) NamedValue(org.alfresco.webservice.types.NamedValue) Predicate(org.alfresco.webservice.types.Predicate) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) QueryResult(org.alfresco.webservice.repository.QueryResult) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) ResultSet(org.alfresco.webservice.types.ResultSet) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException)

Example 5 with ContentDTO

use of com.tomasio.projects.trainning.dto.ContentDTO in project trainning by fernandotomasio.

the class ImagesController method showIndex.

@RequestMapping({ "/", "/index", "" })
public String showIndex(Model model, WebRequest request) {
    List result = new ArrayList();
    String folderId = request.getParameter("folder");
    ContentDTO[] contents = ecmService.findAllContentByUUID(folderId);
    if (contents != null) {
        for (ContentDTO content : contents) {
            Map item = new HashMap();
            item.put("uid", content.getUid());
            result.add(item);
        }
    }
    model.addAttribute("itens", result);
    return "images";
}
Also used : ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ContentDTO (com.tomasio.projects.trainning.dto.ContentDTO)6 RemoteException (java.rmi.RemoteException)4 AuthenticationFault (org.alfresco.webservice.authentication.AuthenticationFault)3 QueryResult (org.alfresco.webservice.repository.QueryResult)3 RepositoryFault (org.alfresco.webservice.repository.RepositoryFault)3 RepositoryServiceSoapBindingStub (org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub)3 NamedValue (org.alfresco.webservice.types.NamedValue)3 Node (org.alfresco.webservice.types.Node)3 Predicate (org.alfresco.webservice.types.Predicate)3 Query (org.alfresco.webservice.types.Query)3 Reference (org.alfresco.webservice.types.Reference)3 ResultSetRow (org.alfresco.webservice.types.ResultSetRow)3 AlfrescoContentDAO (com.tomasio.projects.trainning.dao.AlfrescoContentDAO)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ParentReference (org.alfresco.webservice.types.ParentReference)2 ResultSet (org.alfresco.webservice.types.ResultSet)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ContentDAO (com.tomasio.projects.trainning.dao.ContentDAO)1 HibernateTurmaDAO (com.tomasio.projects.trainning.dao.HibernateTurmaDAO)1