Search in sources :

Example 6 with ProjectFileSystem

use of com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem in project be5 by DevelopmentOnTheEdge.

the class WatchDir method registerAll.

private void registerAll(final ProjectFileSystem fs) throws IOException {
    Path start = fs.getRoot();
    NavigableMap<Path, Boolean> map = fs.getPaths();
    // register directory and sub-directories
    Files.walkFileTree(start, new SimpleFileVisitor<Path>() {

        @Override
        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
            Path parent = StreamEx.iterate(dir, Path::getParent).takeWhile(Objects::nonNull).findFirst(map::containsKey).orElse(null);
            boolean hasChildren = StreamEx.ofKeys(map).anyMatch(path -> path.startsWith(dir));
            if (parent == null || !map.get(parent) && !parent.equals(dir))
                return hasChildren ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
            register(dir);
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            lastModifiedByPath.put(file, file.toFile().lastModified());
            return FileVisitResult.CONTINUE;
        }
    });
}
Also used : Path(java.nio.file.Path) JULLogger(com.developmentontheedge.be5.metadata.util.JULLogger) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WatchKey(java.nio.file.WatchKey) LinkOption(java.nio.file.LinkOption) StandardWatchEventKinds(java.nio.file.StandardWatchEventKinds) Map(java.util.Map) Path(java.nio.file.Path) ProcessController(com.developmentontheedge.be5.metadata.util.ProcessController) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) Files(java.nio.file.Files) WatchEvent(java.nio.file.WatchEvent) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) NavigableMap(java.util.NavigableMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Consumer(java.util.function.Consumer) FileVisitResult(java.nio.file.FileVisitResult) WatchService(java.nio.file.WatchService) List(java.util.List) StreamEx(one.util.streamex.StreamEx) Project(com.developmentontheedge.be5.metadata.model.Project) FileSystems(java.nio.file.FileSystems) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 7 with ProjectFileSystem

use of com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

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

Example 8 with ProjectFileSystem

use of com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final BeConnectionProfiles connectionProfiles) throws WriteException {
    this.fileSystem = new ProjectFileSystem(connectionProfiles.getProject());
    new ConnectionProfilesSerializer().serialize(connectionProfiles.getType(), connectionProfiles);
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Example 9 with ProjectFileSystem

use of com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem 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 10 with ProjectFileSystem

use of com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem 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)

Aggregations

ProjectFileSystem (com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)10 Project (com.developmentontheedge.be5.metadata.model.Project)3 Path (java.nio.file.Path)3 IOException (java.io.IOException)2 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)1 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 ProjectFileStructure (com.developmentontheedge.be5.metadata.model.ProjectFileStructure)1 BeModelCollection (com.developmentontheedge.be5.metadata.model.base.BeModelCollection)1 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)1 JULLogger (com.developmentontheedge.be5.metadata.util.JULLogger)1 ProcessController (com.developmentontheedge.be5.metadata.util.ProcessController)1 FileSystems (java.nio.file.FileSystems)1 FileVisitResult (java.nio.file.FileVisitResult)1 Files (java.nio.file.Files)1 LinkOption (java.nio.file.LinkOption)1 Paths (java.nio.file.Paths)1 SimpleFileVisitor (java.nio.file.SimpleFileVisitor)1 StandardWatchEventKinds (java.nio.file.StandardWatchEventKinds)1 WatchEvent (java.nio.file.WatchEvent)1 WatchKey (java.nio.file.WatchKey)1