use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ReadModelFromXmlTest method testWriteReadLocalizations.
@Test
public void testWriteReadLocalizations() throws Exception {
final Project project = new Project("test");
final Localizations localizations = project.getApplication().getLocalizations();
localizations.addLocalization("en", "entity", Arrays.asList("topic"), "hello", "Hello!");
localizations.addLocalization("de", "entity", Arrays.asList("topic", "topic2"), "hello", "Guten Tag!");
localizations.addLocalization("it", "entity", Arrays.asList("topic2"), "hello", "Buon giorno!");
final Path tempFolder = Files.createTempDirectory("be4-temp");
Serialization.save(project, tempFolder);
final Project project2 = Serialization.load(tempFolder);
final Localizations localizations2 = project2.getApplication().getLocalizations();
assertEquals("Hello!", localizations2.get("en").get("entity").elements().iterator().next().getValue());
assertEquals("Guten Tag!", localizations2.get("de").get("entity").elements().iterator().next().getValue());
assertEquals("Buon giorno!", localizations2.get("it").get("entity").elements().iterator().next().getValue());
FileUtils.deleteRecursively(tempFolder);
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class VariableSelector method getTags.
@Override
public String[] getTags() {
Project project = ((BeModelElement) getBean()).getProject();
Map<String, String> variableNames = project.getVariables();
String[] result = new String[variableNames.size() + 1];
result[0] = "(none)";
int i = 1;
for (Entry<String, String> entry : variableNames.entrySet()) {
result[i++] = entry.getKey() + " (" + entry.getValue() + ")";
}
return result;
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class SelectorTest method testMatch.
@Test
public void testMatch() throws ParseException {
Project project = new Project("test");
Module app = project.getApplication();
Module mod = new Module("mod", project.getModules());
DataElementUtils.save(mod);
Entity appTable = new Entity("appTable", app, EntityType.TABLE);
DataElementUtils.save(appTable);
DataElementUtils.save(new Query("All records", appTable));
Entity appDict = new Entity("appDict", app, EntityType.DICTIONARY);
DataElementUtils.save(appDict);
Query dictRecords = new Query("All records", appDict);
dictRecords.setInvisible(true);
DataElementUtils.save(dictRecords);
Entity modTable = new Entity("modTable", mod, EntityType.DICTIONARY);
DataElementUtils.save(modTable);
DataElementUtils.save(new Query("All records", modTable));
SelectorRule rule1 = UnionSelectorRule.create("Query[invisible=true]");
assertEquals("Query[invisible=true]", rule1.toString());
checkRule(rule1, "test/application/Entities/appDict/Queries/All records", project);
SelectorRule rule2 = UnionSelectorRule.create(".table Query[name=\"All records\"]");
assertEquals(".table Query[name=\"All records\"]", rule2.toString());
checkRule(rule2, "test/application/Entities/appTable/Queries/All records", project);
SelectorRule rule3 = UnionSelectorRule.create("Module#mod Query[name=\"All records\"]");
assertEquals("Module#mod Query[name=\"All records\"]", rule3.toString());
checkRule(rule3, "test/Modules/mod/Entities/modTable/Queries/All records", project);
SelectorRule rule4 = UnionSelectorRule.create("Entity:not(.dictionary)");
assertEquals("Entity:not(.dictionary)", rule4.toString());
checkRule(rule4, "test/application/Entities/appTable", project);
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class AppValidate method saveProject.
// private List<ProjectElementException> validateDeps( List<Project> moduleProjects )
// {
// List<ProjectElementException> moduleErrors = new ArrayList<>();
// Map<String, String> entityToModule = new HashMap<>();
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// entityToModule.put( entity.getName(), prj.getName() );
// }
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// {
// for(TableReference ref : entity.getAllReferences())
// {
// String moduleTo = entityToModule.get( ref.getTableTo() );
// if(moduleTo != null && prj.getModule( moduleTo ) == null)
// {
// moduleErrors.add( new ProjectElementException( ref, "Reference to entity '" + ref.getTableTo()
// + "' which is defined in module '" + moduleTo + "' which is not specified in dependencies of module '"
// + prj.getName() + "'" ) );
// }
// }
// }
// }
// return moduleErrors;
// }
private void saveProject() throws MojoFailureException {
if (saveProject) {
try {
getLog().info("Saving...");
Serialization.save(be5Project, be5Project.getLocation());
} catch (ProjectSaveException e) {
throw new MojoFailureException("Can not save project.", e);
}
}
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class AppValidate method validateProject.
private void validateProject() throws MojoFailureException {
List<ProjectElementException> errors = new ArrayList<>();
if (skipValidation) {
getLog().info("Validation skipped");
} else {
getLog().info("Validating...");
errors.addAll(be5Project.getErrors());
int count = 0;
for (ProjectElementException error : errors) {
if (error.getPath().equals(be5Project.getName()) && error.getProperty().equals("connectionProfileName"))
continue;
count++;
displayError(error);
}
if (count > 0) {
throw new MojoFailureException("Project has " + count + " errors.");
}
getLog().info("Project is valid.");
skipValidation = true;
}
}
Aggregations