use of org.meveo.model.module.MeveoModule in project meveo by meveo-org.
the class StartupListener method createMeveoModule.
private void createMeveoModule(GitRepository meveoRepository) throws BusinessException {
MeveoModule meveoModule = meveoModuleService.findByCode("Meveo");
if (meveoModule == null) {
meveoModule = new MeveoModule();
meveoModule.setCode("Meveo");
meveoModule.setCurrentVersion("1.0.0");
meveoModule.setInstalled(true);
meveoModule.setDescription("Main module");
meveoModule.setGitRepository(meveoRepository);
meveoModuleService.create(meveoModule);
}
}
use of org.meveo.model.module.MeveoModule in project meveo by meveo-org.
the class CustomRelationshipTemplateService method create.
@Override
public void create(CustomRelationshipTemplate crt) throws BusinessException {
if (!EntityCustomizationUtils.validateOntologyCode(crt.getCode())) {
throw new IllegalArgumentException("The code of ontology elements must not contain numbers");
}
if (crt.getStartNode() == null) {
throw new IllegalArgumentException("Can't create relation " + crt.getCode() + ": start node can't be null");
}
if (crt.getEndNode() == null) {
throw new IllegalArgumentException("Can't create relation " + crt.getCode() + ": end node can't be null");
}
super.create(crt);
try {
permissionService.createIfAbsent(crt.getModifyPermission(), paramBean.getProperty("role.modifyAllCR", "ModifyAllCR"));
permissionService.createIfAbsent(crt.getReadPermission(), paramBean.getProperty("role.readAllCR", "ReadAllCR"));
if (crt.getAvailableStorages().contains(DBStorageType.SQL)) {
customTableCreatorService.createCrtTable(crt);
}
customFieldsCache.addUpdateCustomRelationshipTemplate(crt);
} catch (Exception e) {
throw new RuntimeException(e);
}
// Synchronize start and end CETs
CustomEntityTemplate startCet = crt.getStartNode();
MeveoModule cetModule = cetService.findModuleOf(startCet);
cetService.addFilesToModule(startCet, cetModule);
CustomEntityTemplate endCrt = crt.getEndNode();
MeveoModule cet2Module = cetService.findModuleOf(endCrt);
cetService.addFilesToModule(endCrt, cet2Module);
}
use of org.meveo.model.module.MeveoModule in project meveo by meveo-org.
the class CustomRelationshipTemplateService method getCrtDir.
/**
* Get directory the java or the json schema of a crt
* @param crt code your a looking for
* @param extension the file you target (json or java)
* @return file
*/
public File getCrtDir(CustomRelationshipTemplate crt, String extension) {
File repositoryDir;
String path;
String directory = "";
if (extension == "json") {
directory = "/facets/json";
} else if (extension == "java") {
// + crt.getClass().getAnnotation(ModuleItem.class).path();
directory = "/facets/java/org/meveo/model/customEntities";
}
MeveoModule module = customRelationshipTemplateService.findModuleOf(crt);
if (module == null) {
repositoryDir = GitHelper.getRepositoryDir(currentUser, meveoRepository.getCode());
path = directory;
} else {
repositoryDir = GitHelper.getRepositoryDir(currentUser, module.getGitRepository().getCode());
path = directory;
}
return new File(repositoryDir, path);
}
use of org.meveo.model.module.MeveoModule in project meveo by meveo-org.
the class CustomRelationshipTemplateService method remove.
@Override
public void remove(CustomRelationshipTemplate crt) throws BusinessException {
Map<String, CustomFieldTemplate> fields = customFieldTemplateService.findByAppliesToNoCache(crt.getAppliesTo());
for (CustomFieldTemplate cft : fields.values()) {
customFieldTemplateService.remove(cft.getId());
}
if (crt.getAvailableStorages().contains(DBStorageType.SQL)) {
customTableCreatorService.removeTable(repositoryService.findDefaultRepository().getCode(), SQLStorageConfiguration.getDbTablename(crt));
}
customFieldsCache.removeCustomRelationshipTemplate(crt);
permissionService.removeIfPresent(crt.getModifyPermission());
permissionService.removeIfPresent(crt.getReadPermission());
super.remove(crt);
CustomEntityTemplate startCet = crt.getStartNode();
MeveoModule cetModule = cetService.findModuleOf(startCet);
cetService.addFilesToModule(startCet, cetModule);
CustomEntityTemplate endCrt = crt.getEndNode();
MeveoModule cet2Module = cetService.findModuleOf(endCrt);
cetService.addFilesToModule(endCrt, cet2Module);
}
use of org.meveo.model.module.MeveoModule in project meveo by meveo-org.
the class CustomEntityInstanceObserver method onRemoved.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onRemoved(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Removed CustomEntityInstance cei) throws BusinessException {
log.debug("CEI onRemoved observer={}", cei);
BusinessService businessService = businessServiceFinder.find(cei);
MeveoModule module = businessService.findModuleOf(cei);
try {
if (module != null) {
businessService.removeFilesFromModule(cei, module);
}
} catch (BusinessException e) {
throw new BusinessException("CEI: " + cei.getCode() + " cannot be removed");
}
}
Aggregations