Search in sources :

Example 16 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project ontrack by nemerosa.

the class PropertyJdbcRepository method saveProperty.

@Override
@CacheEvict(cacheNames = "properties", key = "#typeName + #entityType.name() + #entityId.value")
public void saveProperty(String typeName, ProjectEntityType entityType, ID entityId, JsonNode data, String searchKey) {
    MapSqlParameterSource params = params("type", typeName).addValue("entityId", entityId.getValue());
    // Any previous value?
    Integer propertyId = getFirstItem(String.format("SELECT ID FROM PROPERTIES WHERE TYPE = :type AND %s = :entityId", entityType.name()), params, Integer.class);
    // Data parameters
    params.addValue("json", writeJson(data)).addValue("searchKey", searchKey);
    // Update
    if (propertyId != null) {
        getNamedParameterJdbcTemplate().update("UPDATE PROPERTIES SET JSON = :json, SEARCHKEY = :searchKey WHERE ID = :id", params.addValue("id", propertyId));
    } else // Creation
    {
        getNamedParameterJdbcTemplate().update(String.format("INSERT INTO PROPERTIES(TYPE, %s, SEARCHKEY, JSON) " + "VALUES(:type, :entityId, :searchKey, :json)", entityType.name()), params);
    }
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 17 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project metacat by Netflix.

the class ConnectorTableServiceProxy method update.

/**
 * Calls the connector table service update method.
 * @param name table name
 * @param tableInfo table object
 * @return true if errors after this should be ignored.
 */
@CacheEvict(key = "'table.' + #name")
public boolean update(final QualifiedName name, final TableInfo tableInfo) {
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    final ConnectorTableService service = connectorManager.getTableService(name);
    boolean result = false;
    try {
        log.info("Updating table {}", name);
        final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
        service.update(connectorRequestContext, tableInfo);
        result = connectorRequestContext.isIgnoreErrorsAfterUpdate();
    } catch (UnsupportedOperationException ignored) {
        // Ignore if the operation is not supported, so that we can at least go ahead and save the user metadata.
        log.debug("Catalog {} does not support the table update operation.", name.getCatalogName());
    }
    return result;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorTableService(com.netflix.metacat.common.server.connectors.ConnectorTableService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 18 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project cu-kfs by CU-CommunityApps.

the class ParameterRepositoryServiceImpl method createParameter.

@CacheEvict(value = Parameter.CACHE_NAME, allEntries = true)
@Override
public Parameter createParameter(Parameter parameter) {
    if (parameter == null) {
        throw new IllegalArgumentException("parameter is null");
    }
    final ParameterKey key = ParameterKey.create(parameter.getNamespaceCode(), parameter.getComponentCode(), parameter.getName());
    final Parameter existing = getParameter(key);
    if (existing != null) {
        throw new IllegalStateException("the parameter to create already exists: " + parameter);
    }
    return businessObjectService.save(parameter);
}
Also used : ParameterKey(org.kuali.kfs.coreservice.api.parameter.ParameterKey) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 19 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project cu-kfs by CU-CommunityApps.

the class ParameterRepositoryServiceImpl method updateParameter.

@CacheEvict(value = Parameter.CACHE_NAME, allEntries = true)
@Override
public Parameter updateParameter(Parameter parameter) {
    if (parameter == null) {
        throw new IllegalArgumentException("parameter is null");
    }
    final ParameterKey key = ParameterKey.create(parameter.getNamespaceCode(), parameter.getComponentCode(), parameter.getName());
    final Parameter existing = getParameter(key);
    if (existing == null) {
        throw new IllegalStateException("the parameter does not exist: " + parameter);
    }
    return businessObjectService.save(parameter);
}
Also used : ParameterKey(org.kuali.kfs.coreservice.api.parameter.ParameterKey) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 20 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project fw-cloud-framework by liuweijw.

the class RoleServiceImpl method saveRoleAndDept.

@Override
@Transactional
@CacheEvict(allEntries = true)
public Role saveRoleAndDept(Role role) {
    if (null == role || null == role.getDeptId() || role.getDeptId() < 0)
        return null;
    Role dbRole = this.roleRepository.saveAndFlush(role);
    // 删除之前保存的部门角色关系
    QRoleDept qRoleDept = QRoleDept.roleDept;
    this.queryFactory.delete(qRoleDept).where(qRoleDept.roleId.eq(dbRole.getRoleId())).execute();
    RoleDept roleDept = new RoleDept();
    roleDept.setDeptId(role.getDeptId());
    roleDept.setRoleId(dbRole.getRoleId());
    roleDeptRepository.saveAndFlush(roleDept);
    return dbRole;
}
Also used : Role(com.github.liuweijw.business.admin.domain.Role) QRole(com.github.liuweijw.business.admin.domain.QRole) RoleDept(com.github.liuweijw.business.admin.domain.RoleDept) QRoleDept(com.github.liuweijw.business.admin.domain.QRoleDept) QRoleDept(com.github.liuweijw.business.admin.domain.QRoleDept) CacheEvict(org.springframework.cache.annotation.CacheEvict) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

CacheEvict (org.springframework.cache.annotation.CacheEvict)53 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)14 Transactional (org.springframework.transaction.annotation.Transactional)13 Date (java.util.Date)8 ArrayList (java.util.ArrayList)6 CacheInfoEvict (org.entando.entando.aps.system.services.cache.CacheInfoEvict)5 QUser (com.github.liuweijw.business.admin.domain.QUser)3 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)3 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)3 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)3 QMenu (com.github.liuweijw.business.admin.domain.QMenu)2 QRole (com.github.liuweijw.business.admin.domain.QRole)2 QUserRole (com.github.liuweijw.business.admin.domain.QUserRole)2 Role (com.github.liuweijw.business.admin.domain.Role)2 User (com.github.liuweijw.business.admin.domain.User)2 UserRole (com.github.liuweijw.business.admin.domain.UserRole)2 AuthUser (com.github.liuweijw.system.api.model.AuthUser)2 RoleMenuDO (io.github.tesla.ops.system.domain.RoleMenuDO)2 Connection (java.sql.Connection)2 HashMap (java.util.HashMap)2