Search in sources :

Example 1 with MeveoModule

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);
    }
}
Also used : MeveoModule(org.meveo.model.module.MeveoModule)

Example 2 with 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);
}
Also used : CustomEntityTemplate(org.meveo.model.customEntities.CustomEntityTemplate) MeveoModule(org.meveo.model.module.MeveoModule) NoResultException(javax.persistence.NoResultException) IOException(java.io.IOException) BusinessException(org.meveo.admin.exception.BusinessException)

Example 3 with MeveoModule

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);
}
Also used : File(java.io.File) MeveoModule(org.meveo.model.module.MeveoModule)

Example 4 with MeveoModule

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);
}
Also used : CustomEntityTemplate(org.meveo.model.customEntities.CustomEntityTemplate) CustomFieldTemplate(org.meveo.model.crm.CustomFieldTemplate) MeveoModule(org.meveo.model.module.MeveoModule)

Example 5 with MeveoModule

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");
    }
}
Also used : BusinessService(org.meveo.service.base.BusinessService) BusinessException(org.meveo.admin.exception.BusinessException) MeveoModule(org.meveo.model.module.MeveoModule) TransactionAttribute(javax.ejb.TransactionAttribute)

Aggregations

MeveoModule (org.meveo.model.module.MeveoModule)69 BusinessException (org.meveo.admin.exception.BusinessException)23 EntityDoesNotExistsException (org.meveo.api.exception.EntityDoesNotExistsException)20 File (java.io.File)18 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)18 MeveoModuleItem (org.meveo.model.module.MeveoModuleItem)18 CustomFieldTemplate (org.meveo.model.crm.CustomFieldTemplate)10 CustomEntityTemplate (org.meveo.model.customEntities.CustomEntityTemplate)9 MeveoModuleDto (org.meveo.api.dto.module.MeveoModuleDto)8 MeveoApiException (org.meveo.api.exception.MeveoApiException)7 HashMap (java.util.HashMap)6 TransactionAttribute (javax.ejb.TransactionAttribute)6 ActionForbiddenException (org.meveo.api.exception.ActionForbiddenException)6 Map (java.util.Map)5 NoResultException (javax.persistence.NoResultException)5 BusinessEntity (org.meveo.model.BusinessEntity)5 CustomRelationshipTemplate (org.meveo.model.customEntities.CustomRelationshipTemplate)5 GitRepository (org.meveo.model.git.GitRepository)5 MeveoModuleDependency (org.meveo.model.module.MeveoModuleDependency)5