Search in sources :

Example 31 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class LanguageSelector method getState.

private LanguageSelectorResponse getState(Injector injector) {
    Project project = injector.getProject();
    List<String> languages = Arrays.stream(project.getLanguages()).map(String::toUpperCase).collect(Collectors.toList());
    String selectedLanguage = UserInfoHolder.getLanguage().toUpperCase();
    Map<String, String> messages = readMessages(project, selectedLanguage);
    return new LanguageSelectorResponse(languages, selectedLanguage, messages);
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project)

Example 32 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class Serialization method load.

/**
 * @param root
 * @param fuseTemplates whether to fuse templates into entities (useful for modules loading)
 * @param loadContext
 * @return
 * @throws ProjectLoadException
 * @see Serialization#canBeLoaded(Path)
 */
public static Project load(final Path root, final boolean fuseTemplates, final LoadContext loadContext) throws ProjectLoadException {
    Objects.requireNonNull(root);
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(loadContext == null ? new LoadContext() : loadContext, fuseTemplates).readProject(root);
    } catch (final ReadException e) {
        throw new ProjectLoadException(root, e);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 33 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method deserializeConnectionProfile.

/**
 * Parses a connection profile. Doesn't save it to connection profiles
 * collection.
 *
 * @param serialized
 *            Must contain a serialized JSON with a map as a root element.
 *            This map should have only one key, that represents a
 *            connection profile name. The value should contain pairs of connection profile fields.
 * @throws ReadException
 * @throws ClassCastException
 * @see Fields#connectionProfile()
 * @see Fields#connectionProfileRead()
 */
public static BeConnectionProfile deserializeConnectionProfile(final LoadContext loadContext, final String serialized, final Project project) throws ReadException {
    // unsafe
    @SuppressWarnings("unchecked") final LinkedHashMap<String, Object> namedProfile = (LinkedHashMap<String, Object>) new Yaml().load(serialized);
    final String profileName = namedProfile.keySet().iterator().next();
    // unsafe
    @SuppressWarnings("unchecked") final Map<String, Object> serializedProfileBody = (Map<String, Object>) namedProfile.get(profileName);
    final BeConnectionProfile profile = readConnectionProfile(loadContext, profileName, serializedProfileBody, project);
    return profile;
}
Also used : BeConnectionProfile(com.developmentontheedge.be5.metadata.model.BeConnectionProfile) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Yaml(org.yaml.snakeyaml.Yaml) LinkedHashMap(java.util.LinkedHashMap)

Example 34 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method readProjectFileStructure.

private ProjectFileStructure readProjectFileStructure(BaseDeserializer deserializer, final Map<String, Object> serializedPfs, final Project project) {
    final ProjectFileStructure pfs = new ProjectFileStructure(project);
    deserializer.readFields(pfs, serializedPfs, Fields.projectFileStructure());
    return pfs;
}
Also used : ProjectFileStructure(com.developmentontheedge.be5.metadata.model.ProjectFileStructure)

Example 35 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method reloadSecurityCollection.

public SecurityCollection reloadSecurityCollection(final Path path, final Project project) throws ReadException {
    final SecurityCollection security = project.newSecurityCollection();
    final SecurityDeserializer securityDeserializer = new SecurityDeserializer(path, security);
    securityDeserializer.deserialize();
    DataElementUtils.saveQuiet(securityDeserializer.getResult());
    return securityDeserializer.getResult();
}
Also used : SecurityCollection(com.developmentontheedge.be5.metadata.model.SecurityCollection)

Aggregations

Project (com.developmentontheedge.be5.metadata.model.Project)40 Module (com.developmentontheedge.be5.metadata.model.Module)19 Test (org.junit.Test)19 Entity (com.developmentontheedge.be5.metadata.model.Entity)14 Path (java.nio.file.Path)13 Query (com.developmentontheedge.be5.metadata.model.Query)12 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)7 ArrayList (java.util.ArrayList)7 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)6 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)5 URL (java.net.URL)5 Map (java.util.Map)5 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)4 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)4 Operation (com.developmentontheedge.be5.metadata.model.Operation)4 IOException (java.io.IOException)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)3 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)3 Localizations (com.developmentontheedge.be5.metadata.model.Localizations)3