Skip to content

Commit

Permalink
rename update
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Sep 18, 2024
1 parent 74e4efb commit edb1ad3
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public interface BaseDao<Entity> {
/**
* Update the entity by primary key.
*/
@UpdateProvider(type = BaseSqlProvider.class, method = "updateById")
int updateById(Entity entity);
@UpdateProvider(type = BaseSqlProvider.class, method = "partialUpdateById")
int partialUpdateById(Entity entity);

/**
* Query the entity by primary key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public <Entity> String insert(Entity entity, ProviderContext context) {
return SQLBuilder.insert(tableMetaData, entity, databaseId);
}

public <Entity> String updateById(Entity entity, ProviderContext context) {
public <Entity> String partialUpdateById(Entity entity, ProviderContext context) {
Assert.notNull(entity, "entity must not null");

String databaseId = context.getDatabaseId();

Class<?> entityClass = entity.getClass();
TableMetaData tableMetaData = TableMetaData.forClass(entityClass);

return SQLBuilder.update(tableMetaData, entity, databaseId);
return SQLBuilder.partialUpdate(tableMetaData, entity, databaseId);
}

public String selectById(Serializable id, ProviderContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static <Entity> String insert(TableMetaData tableMetaData, Entity entity,
return sql.toString();
}

public static <Entity> String update(TableMetaData tableMetaData, Entity entity, String databaseId) {
public static <Entity> String partialUpdate(TableMetaData tableMetaData, Entity entity, String databaseId) {
Class<?> entityClass = entity.getClass();
Map<String, String> fieldColumnMap = tableMetaData.getFieldColumnMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void beforeCreateStages() {
@Override
public void beforeRun() {
jobPO.setState(JobState.PROCESSING.getName());
jobDao.updateById(jobPO);
jobDao.partialUpdateById(jobPO);
}

@Override
Expand Down Expand Up @@ -124,7 +124,7 @@ public void run() {
public void onSuccess() {
JobPO jobPO = getJobPO();
jobPO.setState(JobState.SUCCESSFUL.getName());
jobDao.updateById(jobPO);
jobDao.partialUpdateById(jobPO);
}

@Override
Expand Down Expand Up @@ -154,7 +154,7 @@ public void onFailure() {
if (!stagePOList.isEmpty()) {
stageDao.updateStateByIds(stagePOList);
}
jobDao.updateById(jobPO);
jobDao.partialUpdateById(jobPO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ public void onSuccess() {

// Update cluster state to installed
clusterPO.setState(MaintainState.INSTALLED.getName());
clusterDao.updateById(clusterPO);
clusterDao.partialUpdateById(clusterPO);

// Link job to cluster after cluster successfully added
JobPO jobPO = getJobPO();
jobPO.setClusterId(clusterPO.getId());
jobDao.updateById(jobPO);
jobDao.partialUpdateById(jobPO);

for (Stage stage : getStages()) {
StagePO stagePO = stage.getStagePO();
stagePO.setClusterId(clusterPO.getId());
stageDao.updateById(stagePO);
stageDao.partialUpdateById(stagePO);

for (Task task : stage.getTasks()) {
TaskPO taskPO = task.getTaskPO();
taskPO.setClusterId(clusterPO.getId());
taskDao.updateById(taskPO);
taskDao.partialUpdateById(taskPO);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected String getComponentName() {
@Override
public void beforeRun() {
stagePO.setState(JobState.PROCESSING.getName());
stageDao.updateById(stagePO);
stageDao.partialUpdateById(stagePO);
}

@Override
Expand Down Expand Up @@ -121,14 +121,14 @@ public Boolean run() {
public void onSuccess() {
StagePO stagePO = getStagePO();
stagePO.setState(JobState.SUCCESSFUL.getName());
stageDao.updateById(stagePO);
stageDao.partialUpdateById(stagePO);
}

@Override
public void onFailure() {
StagePO stagePO = getStagePO();
stagePO.setState(JobState.FAILED.getName());
stageDao.updateById(stagePO);
stageDao.partialUpdateById(stagePO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected String getCustomCommand() {
@Override
public void beforeRun() {
taskPO.setState(JobState.PROCESSING.getName());
taskDao.updateById(taskPO);
taskDao.partialUpdateById(taskPO);
}

@Override
Expand Down Expand Up @@ -106,15 +106,15 @@ public void onSuccess() {
TaskPO taskPO = getTaskPO();
taskPO.setContent(ProtobufUtil.toJson(commandRequest));
taskPO.setState(JobState.SUCCESSFUL.getName());
taskDao.updateById(taskPO);
taskDao.partialUpdateById(taskPO);
}

@Override
public void onFailure() {
TaskPO taskPO = getTaskPO();
taskPO.setContent(ProtobufUtil.toJson(commandRequest));
taskPO.setState(JobState.FAILED.getName());
taskDao.updateById(taskPO);
taskDao.partialUpdateById(taskPO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onSuccess() {
HostComponentPO hostComponentPO =
hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
hostComponentPO.setState(MaintainState.INSTALLED.getName());
hostComponentDao.updateById(hostComponentPO);
hostComponentDao.partialUpdateById(hostComponentPO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onSuccess() {
HostComponentPO hostComponentPO =
hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
hostComponentPO.setState(MaintainState.STARTED.getName());
hostComponentDao.updateById(hostComponentPO);
hostComponentDao.partialUpdateById(hostComponentPO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onSuccess() {
HostComponentPO hostComponentPO =
hostComponentDao.findByClusterIdAndComponentNameAndHostname(clusterId, componentName, hostname);
hostComponentPO.setState(MaintainState.STOPPED.getName());
hostComponentDao.updateById(hostComponentPO);
hostComponentDao.partialUpdateById(hostComponentPO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public void execute() {
if (reply.getStatus() == 0
&& MaintainState.fromString(hostComponentPO.getState()) == MaintainState.STOPPED) {
hostComponentPO.setState(MaintainState.STARTED.getName());
hostComponentDao.updateById(hostComponentPO);
hostComponentDao.partialUpdateById(hostComponentPO);
}

if (reply.getStatus() != 0
&& MaintainState.fromString(hostComponentPO.getState()) == MaintainState.STARTED) {
hostComponentPO.setState(MaintainState.STOPPED.getName());
hostComponentDao.updateById(hostComponentPO);
hostComponentDao.partialUpdateById(hostComponentPO);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ private void getHostInfo(HostPO hostPO) {
hostPO.setState(MaintainState.STOPPED.getName());
}

hostDao.updateById(hostPO);
hostDao.partialUpdateById(hostPO);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ClusterVO save(ClusterDTO clusterDTO) {
clusterDao.findByClusterName(clusterDTO.getClusterName()).orElse(new ClusterPO());
if (oldClusterPO.getId() != null) {
clusterPO.setId(oldClusterPO.getId());
clusterDao.updateById(clusterPO);
clusterDao.partialUpdateById(clusterPO);
} else {
clusterDao.save(clusterPO);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public ClusterVO get(Long id) {
public ClusterVO update(Long id, ClusterDTO clusterDTO) {
ClusterPO clusterPO = ClusterConverter.INSTANCE.fromDTO2PO(clusterDTO);
clusterPO.setId(id);
clusterDao.updateById(clusterPO);
clusterDao.partialUpdateById(clusterPO);

return ClusterConverter.INSTANCE.fromEntity2VO(clusterPO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void upsertServiceConfig(
if (shouldUpdateConfig(existConfigs, configs)) {
// Unselect current config
currentConfig.setSelected(false);
serviceConfigDao.updateById(currentConfig);
serviceConfigDao.partialUpdateById(currentConfig);

// Create a new config
String configDesc = "Update config for " + servicePO.getServiceName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public HostVO get(Long id) {
public HostVO update(Long id, HostDTO hostDTO) {
HostPO hostPO = HostConverter.INSTANCE.fromDTO2PO(hostDTO);
hostPO.setId(id);
hostDao.updateById(hostPO);
hostDao.partialUpdateById(hostPO);

return HostConverter.INSTANCE.fromPO2VO(hostPO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ private void resetJobStatusInDB(JobPO jobPO) {
for (StagePO stagePO : jobPO.getStages()) {
for (TaskPO taskPO : stagePO.getTasks()) {
taskPO.setState(JobState.PENDING.getName());
taskDao.updateById(taskPO);
taskDao.partialUpdateById(taskPO);
}

stagePO.setState(JobState.PENDING.getName());
stageDao.updateById(stagePO);
stageDao.partialUpdateById(stagePO);
}

jobPO.setState(JobState.PENDING.getName());
jobDao.updateById(jobPO);
jobDao.partialUpdateById(jobPO);
}

private Job recreateJob(JobPO jobPO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public UserVO update(UserDTO userDTO) {
Long id = SessionUserHolder.getUserId();
UserPO userPO = userDao.findOptionalById(id).orElseThrow(() -> new ApiException(ApiExceptionEnum.NEED_LOGIN));
userPO.setNickname(userDTO.getNickname());
userDao.updateById(userPO);
userDao.partialUpdateById(userPO);
return UserConverter.INSTANCE.fromPO2VO(userPO);
}
}

0 comments on commit edb1ad3

Please sign in to comment.