Aller au contenu principal

How to get a ProjectEnvironment inside of an executable to init GenericConfiguration object

Commentaires

1 commentaire

  • Zendesk API User
    Author: bIT_sosswald - 8/10/2023 18:32

    I solved the issue with an ugly solution, but it works.

    I created my own implementation of ProjectEnvironment which just returns the needed values to initialize the GenericConfiguration with the method getConfDir().

    When passing the module name, project app name and project I can get the FileHandle to the project app configuration directory which is used by the init() call on the GenericConfiguration panel. - This solves my problem and I can use the GenericConfiguration panel to change project app configurations inside of an executable using a comfortable API.

    public class ProjectAppConfigEnvironment implements ProjectEnvironment {


    private final Project project;
    private final FileSystem<? extends FileHandle> fileSystem;

    /**
    * Creates a new instance.
    *
    * @param moduleName The name of the FirstSpirit module containing the project app in focus.
    * @param projectAppName The name of the project app in focus.
    * @param project The project in which the project app is installed to.
    */
    public ProjectAppConfigEnvironment(String moduleName, String projectAppName, Project project) {
    this.project = project;
    ModuleAdminAgent moduleAdminAgent = project.getUserService().getConnection().getBroker().requireSpecialist(ModuleAdminAgent.TYPE);
    fileSystem = moduleAdminAgent.getProjectAppConfig(moduleName, projectAppName, project);
    }

    /**
    * Gets the configuration directory of the project app.
    *
    * @return Access to the project-app configuration directory.
    * @see <a href="https://docs.e-spirit.com/odfs/dev/de/espirit/firstspirit/agency/ModuleAdminAgent.html#getProjectAppConfig(java.lang.String,java.lang.String,de.espirit.firstspirit.access.project.Project)">ModuleAdminAgent.getProjectAppConfig</a>
    */
    @Override
    public @NotNull FileSystem<? extends FileHandle> getConfDir() {
    return fileSystem;
    }

    @SneakyThrows
    @Override
    public @Nullable FileSystem<? extends FileHandle> getDataDir() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public @Nullable FileSystem<? extends FileHandle> getLogDir() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public Connection getConnection() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public SpecialistsBroker getBroker() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public ComponentDescriptor.Scope getScope() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public @Nullable String getInstalledVersion() {
    throw new OperationNotSupportedException();
    }

    @SneakyThrows
    @Override
    public long getProjectId() {
    return project.getId();
    }

    @SneakyThrows
    @Override
    public @Nullable Project getProject() {
    return project;
    }
    }
    0

Vous devez vous connecter pour laisser un commentaire.