use of org.structr.module.StructrModule in project structr by structr.
the class SchemaHelper method formatImportStatements.
public static void formatImportStatements(final AbstractSchemaNode schemaNode, final StringBuilder src, final Class baseType, final List<String> importStatements) {
src.append("import ").append(baseType.getName()).append(";\n");
src.append("import ").append(ConfigurationProvider.class.getName()).append(";\n");
src.append("import ").append(GraphObjectComparator.class.getName()).append(";\n");
src.append("import ").append(PermissionPropagation.class.getName()).append(";\n");
src.append("import ").append(FrameworkException.class.getName()).append(";\n");
src.append("import ").append(DatePropertyParser.class.getName()).append(";\n");
src.append("import ").append(ModificationQueue.class.getName()).append(";\n");
src.append("import ").append(PropertyConverter.class.getName()).append(";\n");
src.append("import ").append(ValidationHelper.class.getName()).append(";\n");
src.append("import ").append(SecurityContext.class.getName()).append(";\n");
src.append("import ").append(LinkedHashSet.class.getName()).append(";\n");
src.append("import ").append(PropertyView.class.getName()).append(";\n");
src.append("import ").append(GraphObject.class.getName()).append(";\n");
src.append("import ").append(ErrorBuffer.class.getName()).append(";\n");
src.append("import ").append(StringUtils.class.getName()).append(";\n");
src.append("import ").append(Collections.class.getName()).append(";\n");
src.append("import ").append(StructrApp.class.getName()).append(";\n");
src.append("import ").append(LinkedList.class.getName()).append(";\n");
src.append("import ").append(Collection.class.getName()).append(";\n");
src.append("import ").append(Services.class.getName()).append(";\n");
src.append("import ").append(Actions.class.getName()).append(";\n");
src.append("import ").append(HashMap.class.getName()).append(";\n");
src.append("import ").append(Export.class.getName()).append(";\n");
src.append("import ").append(View.class.getName()).append(";\n");
src.append("import ").append(List.class.getName()).append(";\n");
src.append("import ").append(Set.class.getName()).append(";\n");
if (hasRestClasses()) {
src.append("import org.structr.rest.RestMethodResult;\n");
}
src.append("import org.structr.core.property.*;\n");
if (hasUiClasses()) {
src.append("import org.structr.web.property.*;\n");
}
for (final StructrModule module : StructrApp.getConfiguration().getModules().values()) {
module.insertImportStatements(schemaNode, src);
}
src.append("import org.structr.core.notion.*;\n");
src.append("import org.structr.core.entity.*;\n");
// include imports from mixins
for (final String importLine : importStatements) {
src.append(importLine);
src.append("\n");
}
src.append("\n");
}
use of org.structr.module.StructrModule in project structr by structr.
the class DeployCommand method doExport.
private void doExport(final Map<String, Object> attributes) throws FrameworkException {
final String path = (String) attributes.get("target");
if (StringUtils.isBlank(path)) {
throw new FrameworkException(422, "Please provide target path for deployment export.");
}
final Path target = Paths.get(path);
try {
final long startTime = System.currentTimeMillis();
customHeaders.put("start", new Date(startTime).toString());
final Map<String, Object> broadcastData = new HashMap();
broadcastData.put("type", DEPLOYMENT_EXPORT_STATUS);
broadcastData.put("subtype", DEPLOYMENT_STATUS_BEGIN);
broadcastData.put("start", startTime);
broadcastData.put("target", target);
TransactionCommand.simpleBroadcastGenericMessage(broadcastData);
Files.createDirectories(target);
final Path components = Files.createDirectories(target.resolve("components"));
final Path files = Files.createDirectories(target.resolve("files"));
final Path pages = Files.createDirectories(target.resolve("pages"));
final Path schema = Files.createDirectories(target.resolve("schema"));
final Path security = Files.createDirectories(target.resolve("security"));
final Path templates = Files.createDirectories(target.resolve("templates"));
final Path modules = Files.createDirectories(target.resolve("modules"));
final Path schemaJson = schema.resolve("schema.json");
final Path grants = security.resolve("grants.json");
final Path filesConf = target.resolve("files.json");
final Path pagesConf = target.resolve("pages.json");
final Path componentsConf = target.resolve("components.json");
final Path templatesConf = target.resolve("templates.json");
final Path mailTemplates = target.resolve("mail-templates.json");
final Path localizations = target.resolve("localizations.json");
final Path widgets = target.resolve("widgets.json");
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Files");
exportFiles(files, filesConf);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Pages");
exportPages(pages, pagesConf);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Components");
exportComponents(components, componentsConf);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Templates");
exportTemplates(templates, templatesConf);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Resource Access Grants");
exportResourceAccessGrants(grants);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Schema");
exportSchema(schemaJson);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Mail Templates");
exportMailTemplates(mailTemplates);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Localizations");
exportLocalizations(localizations);
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting Widgets");
exportWidgets(widgets);
for (StructrModule module : StructrApp.getConfiguration().getModules().values()) {
if (module.hasDeploymentData()) {
logger.info("Exporting deployment data for module {}", module.getName());
publishDeploymentProgressMessage(DEPLOYMENT_EXPORT_STATUS, "Exporting deployment data for module " + module.getName());
final Path moduleFolder = Files.createDirectories(modules.resolve(module.getName()));
module.exportDeploymentData(moduleFolder, getGson());
}
}
// config import order is "users, grants, pages, components, templates"
// data import order is "schema, files, templates, components, pages"
logger.info("Export finished.");
final long endTime = System.currentTimeMillis();
DecimalFormat decimalFormat = new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
final String duration = decimalFormat.format(((endTime - startTime) / 1000.0)) + "s";
customHeaders.put("end", new Date(endTime).toString());
customHeaders.put("duration", duration);
info("Export to {} done. (Took {})", target.toString(), duration);
broadcastData.put("subtype", DEPLOYMENT_STATUS_END);
broadcastData.put("end", endTime);
broadcastData.put("duration", duration);
TransactionCommand.simpleBroadcastGenericMessage(broadcastData);
} catch (IOException ex) {
logger.warn("", ex);
}
}
Aggregations