Search in sources :

Example 21 with WorkspaceNode

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode in project muikku by otavanopisto.

the class DeusNexMachinaRESTService method cleanMaterials.

private void cleanMaterials(List<WorkspaceNode> nodes) {
    for (WorkspaceNode node : nodes) {
        if (node.getType() != WorkspaceNodeType.MATERIAL) {
            cleanMaterials(workspaceMaterialController.listWorkspaceNodesByParent(node));
        } else {
            WorkspaceMaterial workspaceMaterial = (WorkspaceMaterial) node;
            Material material = workspaceMaterialController.getMaterialForWorkspaceMaterial(workspaceMaterial);
            if ("html".equals(material.getType())) {
                logger.info("Cleaning html material " + material.getId());
                htmlMaterialCleaner.cleanMaterial((HtmlMaterial) material, workspaceMaterial);
            }
        }
    }
}
Also used : Material(fi.otavanopisto.muikku.plugins.material.model.Material) HtmlMaterial(fi.otavanopisto.muikku.plugins.material.model.HtmlMaterial) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)

Example 22 with WorkspaceNode

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode in project muikku by otavanopisto.

the class MaterialUnEmbedder method unembedWorkspaceMaterials.

@Lock
public void unembedWorkspaceMaterials(WorkspaceNode parentNode) throws DeusNexInternalException {
    try {
        loadHtmlMaterialPieces();
        for (WorkspaceNode node : workspaceMaterialController.listWorkspaceNodesByParent(parentNode)) {
            unembedWorkspaceNode(parentNode, node);
        }
        saveHtmlMaterialPieces();
    } catch (XPathExpressionException | SAXException | IOException | ParserConfigurationException | TransformerException | WorkspaceMaterialContainsAnswersExeption e) {
        throw new DeusNexInternalException(e.getClass().getName() + ": " + e.getMessage());
    }
}
Also used : XPathExpressionException(javax.xml.xpath.XPathExpressionException) DeusNexInternalException(fi.otavanopisto.muikku.plugins.dnm.parser.DeusNexInternalException) WorkspaceMaterialContainsAnswersExeption(fi.otavanopisto.muikku.plugins.workspace.WorkspaceMaterialContainsAnswersExeption) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode) TransformerException(javax.xml.transform.TransformerException) SAXException(org.xml.sax.SAXException) Lock(javax.ejb.Lock)

Example 23 with WorkspaceNode

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode in project muikku by otavanopisto.

the class WorkspaceNodeDAO method listByOrderNumberGreater.

public List<WorkspaceNode> listByOrderNumberGreater(WorkspaceNode node) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceNode> criteria = criteriaBuilder.createQuery(WorkspaceNode.class);
    Root<WorkspaceNode> root = criteria.from(WorkspaceNode.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceNode_.parent), node.getParent()), criteriaBuilder.greaterThan(root.get(WorkspaceNode_.orderNumber), node.getOrderNumber())));
    criteria.orderBy(criteriaBuilder.asc(root.get(WorkspaceNode_.orderNumber)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)

Example 24 with WorkspaceNode

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode in project muikku by otavanopisto.

the class WorkspaceNodeDAO method listByOrderNumberEqualOrGreater.

public List<WorkspaceNode> listByOrderNumberEqualOrGreater(WorkspaceNode node) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceNode> criteria = criteriaBuilder.createQuery(WorkspaceNode.class);
    Root<WorkspaceNode> root = criteria.from(WorkspaceNode.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceNode_.parent), node.getParent()), criteriaBuilder.greaterThanOrEqualTo(root.get(WorkspaceNode_.orderNumber), node.getOrderNumber())));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)

Example 25 with WorkspaceNode

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode in project muikku by otavanopisto.

the class WorkspaceMaterialController method listWorkspaceFrontPagesAsContentNodes.

public List<ContentNode> listWorkspaceFrontPagesAsContentNodes(WorkspaceEntity workspaceEntity) throws WorkspaceMaterialException {
    List<ContentNode> contentNodes = new ArrayList<>();
    List<WorkspaceMaterial> frontPages = listFrontPages(workspaceEntity);
    for (WorkspaceNode frontPage : frontPages) {
        ContentNode node = createContentNode(frontPage);
        contentNodes.add(node);
    }
    return contentNodes;
}
Also used : ArrayList(java.util.ArrayList) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)

Aggregations

WorkspaceNode (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)41 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)14 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)11 WorkspaceFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceFolder)11 HtmlMaterial (fi.otavanopisto.muikku.plugins.material.model.HtmlMaterial)9 IOException (java.io.IOException)9 Path (javax.ws.rs.Path)9 ArrayList (java.util.ArrayList)8 EntityManager (javax.persistence.EntityManager)8 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)8 DeusNexInternalException (fi.otavanopisto.muikku.plugins.dnm.parser.DeusNexInternalException)6 Material (fi.otavanopisto.muikku.plugins.material.model.Material)6 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)6 TransformerException (javax.xml.transform.TransformerException)6 XPathExpressionException (javax.xml.xpath.XPathExpressionException)6 SAXException (org.xml.sax.SAXException)6 WorkspaceRootFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceRootFolder)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 Resource (fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Resource)4 WorkspaceMaterialAssignmentType (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAssignmentType)4