Search in sources :

Example 11 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final StaticPages pages) throws WriteException {
    this.fileSystem = new ProjectFileSystem(pages.getProject());
    new StaticPagesSerializer().serialize(pages);
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Example 12 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serializeModules.

private Object serializeModules(final BeModelCollection<Module> modules, boolean serializeReferencedFiles) throws WriteException {
    final List<Object> serializedModules = list();
    for (final Module module : modules) {
        final Map<String, Object> serializedModule = map();
        final Map<String, Object> serializedModuleContent = map();
        final List<Object> serializedEntities = list();
        final Iterable<Entity> entities = module.getEntities();
        for (final Entity entity : entities) if (entity.isCustomized()) {
            if (serializeReferencedFiles)
                new EntitySerializer().serialize(entity);
            serializedEntities.add(entity.getName());
        }
        serializedModuleContent.put(TAG_ENTITIES, serializedEntities);
        final List<Object> serializedExtras = list();
        for (String extra : module.getExtras()) {
            serializedExtras.add(extra);
        }
        if (!serializedExtras.isEmpty()) {
            serializedModuleContent.put(TAG_EXTRAS, serializedExtras);
        }
        serializedModule.put(module.getName(), serializedModuleContent);
        serializedModules.add(serializedModule);
    }
    return serializedModules;
}
Also used : Entity(com.developmentontheedge.be5.metadata.model.Entity) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 13 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serializeToObject.

private Object serializeToObject(final Project project, final boolean serializeReferencedFiles) throws WriteException {
    final Map<String, Object> root = map();
    final Map<String, Object> content = map();
    this.fileSystem = new ProjectFileSystem(project);
    if (project.isModuleProject())
        content.put(ATTR_MODULE_PROJECT, Boolean.valueOf(true));
    serializeDocumentation(project, content);
    content.put(ATTR_FEATURES, list(project.getFeatures()));
    content.put(ATTR_LOCALIZATIONS, list(project.getApplication().getLocalizations().getNameList()));
    serializeBugtrackers(project, content);
    content.put(TAG_PROJECT_FILE_STRUCTURE, serialize(project.getProjectFileStructure()));
    content.put(TAG_MODULES, serializeModules(project.getModules(), serializeReferencedFiles));
    content.put(TAG_APPLICATION, serializeApplication(project.getApplication(), serializeReferencedFiles));
    final List<Object> scriptNames = serializeScripts(project.getApplication().getFreemarkerScripts(), serializeReferencedFiles);
    if (!scriptNames.isEmpty())
        content.put(TAG_SCRIPTS, scriptNames);
    final List<Object> macroFilesNames = serializeMacroFiles(project.getApplication().getMacroCollection(), serializeReferencedFiles);
    if (!macroFilesNames.isEmpty())
        content.put(TAG_MACRO_FILES, macroFilesNames);
    serializeProperties(project, content);
    if (serializeReferencedFiles) {
        serializeDaemons(project.getApplication().getDaemonCollection());
        serializeStaticPages(project.getApplication().getStaticPageCollection());
        serializeSources(project);
        serializeForms(project.getApplication());
        serializeLocalizations(project);
        serializeSecurity(project.getSecurityCollection());
        serializeCustomization(project.getApplication());
        serializeMassChanges(project.getApplication().getMassChangeCollection());
        if (!project.isModuleProject()) {
            serializeConnectionProfiles(project.getConnectionProfiles());
            if (project.getConnectionProfileName() != null) {
                try {
                    fileSystem.writeSelectedProfileFile(project.getConnectionProfileName());
                } catch (IOException e) {
                    throw new WriteException(project, e);
                }
            }
        }
    }
    root.put(project.getName(), content);
    return root;
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem) WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) IOException(java.io.IOException)

Example 14 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final LanguageLocalizations languageLocalizations) throws WriteException {
    this.fileSystem = new ProjectFileSystem(languageLocalizations.getProject());
    new LocalizationSerializer().serialize(languageLocalizations);
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Aggregations

ProjectFileSystem (com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)9 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)4 IOException (java.io.IOException)3 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 ProjectSaveException (com.developmentontheedge.be5.metadata.exception.ProjectSaveException)1 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)1 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 SourceFile (com.developmentontheedge.be5.metadata.model.SourceFile)1 SourceFileCollection (com.developmentontheedge.be5.metadata.model.SourceFileCollection)1 YamlSerializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Path (java.nio.file.Path)1