Some initial work for im/export ui
parent
dbdc197738
commit
5caacee0e8
|
|
@ -89,9 +89,9 @@ public class ImportExport {
|
||||||
*
|
*
|
||||||
* @see CcmFilesConfiguration#dataPath
|
* @see CcmFilesConfiguration#dataPath
|
||||||
*/
|
*/
|
||||||
public void exportEntities(final List<Exportable> entities,
|
public void exportEntities(
|
||||||
final String exportName) {
|
final List<Exportable> entities, final String exportName
|
||||||
|
) {
|
||||||
final JsonObjectBuilder manifestBuilder = Json.createObjectBuilder();
|
final JsonObjectBuilder manifestBuilder = Json.createObjectBuilder();
|
||||||
manifestBuilder.add("created",
|
manifestBuilder.add("created",
|
||||||
LocalDateTime.now(ZoneId.of("UTC")).toString());
|
LocalDateTime.now(ZoneId.of("UTC")).toString());
|
||||||
|
|
@ -152,6 +152,14 @@ public class ImportExport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getExportableEntityTypes() {
|
||||||
|
return imExporters
|
||||||
|
.stream()
|
||||||
|
.map(imexporter -> imexporter.getEntityClass().getName())
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private JsonArrayBuilder createExportedEntities(
|
private JsonArrayBuilder createExportedEntities(
|
||||||
final String exportName,
|
final String exportName,
|
||||||
|
|
@ -429,7 +437,7 @@ public class ImportExport {
|
||||||
// .collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
final JsonArray typesArray = manifestJson.getJsonArray("types");
|
final JsonArray typesArray = manifestJson.getJsonArray("types");
|
||||||
final List<String> types = new ArrayList<>();
|
final List<String> types = new ArrayList<>();
|
||||||
for(int i = 0; i < typesArray.size(); i++) {
|
for (int i = 0; i < typesArray.size(); i++) {
|
||||||
types.add(typesArray.getString(i));
|
types.add(typesArray.getString(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin.imexport;
|
package org.libreccm.ui.admin.imexport;
|
||||||
|
|
||||||
|
import com.arsdigita.ui.admin.importexport.ImportExportMonitor;
|
||||||
|
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
|
import org.libreccm.imexport.ImportExport;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.mvc.Controller;
|
import javax.mvc.Controller;
|
||||||
|
import javax.mvc.Models;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
|
@ -36,11 +41,30 @@ import javax.ws.rs.Path;
|
||||||
@Path("/imexport")
|
@Path("/imexport")
|
||||||
public class ImExportController {
|
public class ImExportController {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ImportExport importExport;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ImportExportMonitor importExportMonitor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Models models;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
public String getImExportDashboard() {
|
public String getImExportDashboard() {
|
||||||
return "org/libreccm/ui/admin/imexport.xhtml";
|
return "org/libreccm/ui/admin/imexport/imexport.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/export")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
|
public String exportEntities() {
|
||||||
|
models.put("exportables", importExport.getExportableEntityTypes());
|
||||||
|
|
||||||
|
return "org/libreccm/ui/admin/imexport/export.xhtml";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||||
|
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
|
||||||
|
|
||||||
|
<ui:param name="activePage" value="imexport" />
|
||||||
|
<ui:param name="title" value="#{AdminMessages['imexport.label']}" />
|
||||||
|
|
||||||
|
<ui:define name="breadcrumb">
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
<a href="#{mvc.uri('ImExportController#getImExportDashboard')}">
|
||||||
|
#{AdminMessages['imexport.label']}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="breadcrumb-item active">
|
||||||
|
#{AdminMessages['imexport.export.label']}
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
<ui:define name="main">
|
||||||
|
<div class="container">
|
||||||
|
<h1>#{AdminMessages['imexport.export.label']}</h1>
|
||||||
|
|
||||||
|
<p>Exportable classes</p>
|
||||||
|
<ul>
|
||||||
|
<c:forEach items="#{exportables}" var="exportable">
|
||||||
|
<li><code>${exportable}</code></li>
|
||||||
|
</c:forEach>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Placeholder</p>
|
||||||
|
</div>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
||||||
Loading…
Reference in New Issue