Add missing index on tag.name (#660)
* Add missing tag name filter for RSQL queries. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add schabdo as commiter. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * DDI API rename and add test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove unneeded text. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add missing auto close. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -31,7 +31,7 @@ public class DdiDeployment {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private List<DdiChunk> chunks;
|
private List<DdiChunk> chunks;
|
||||||
|
|
||||||
private MaintenanceWindowStatus maintenanceWindow;
|
private DdiMaintenanceWindowStatus maintenanceWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -59,7 +59,7 @@ public class DdiDeployment {
|
|||||||
* the parameter is null.
|
* the parameter is null.
|
||||||
*/
|
*/
|
||||||
public DdiDeployment(final HandlingType download, final HandlingType update, final List<DdiChunk> chunks,
|
public DdiDeployment(final HandlingType download, final HandlingType update, final List<DdiChunk> chunks,
|
||||||
final MaintenanceWindowStatus maintenanceWindow) {
|
final DdiMaintenanceWindowStatus maintenanceWindow) {
|
||||||
this.download = download;
|
this.download = download;
|
||||||
this.update = update;
|
this.update = update;
|
||||||
this.chunks = chunks;
|
this.chunks = chunks;
|
||||||
@@ -82,7 +82,7 @@ public class DdiDeployment {
|
|||||||
return Collections.unmodifiableList(chunks);
|
return Collections.unmodifiableList(chunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaintenanceWindowStatus getMaintenanceWindow() {
|
public DdiMaintenanceWindowStatus getMaintenanceWindow() {
|
||||||
return this.maintenanceWindow;
|
return this.maintenanceWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class DdiDeployment {
|
|||||||
/**
|
/**
|
||||||
* Status of the maintenance window for action.
|
* Status of the maintenance window for action.
|
||||||
*/
|
*/
|
||||||
public enum MaintenanceWindowStatus {
|
public enum DdiMaintenanceWindowStatus {
|
||||||
/**
|
/**
|
||||||
* A window is currently available, target can go ahead with
|
* A window is currently available, target can go ahead with
|
||||||
* installation.
|
* installation.
|
||||||
@@ -136,7 +136,7 @@ public class DdiDeployment {
|
|||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
MaintenanceWindowStatus(final String status) {
|
DdiMaintenanceWindowStatus(final String status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.ddi.json.model.DdiConfigData;
|
|||||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment;
|
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment;
|
||||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType;
|
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType;
|
||||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.MaintenanceWindowStatus;
|
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.DdiMaintenanceWindowStatus;
|
||||||
import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase;
|
import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase;
|
||||||
import org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult;
|
import org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult;
|
||||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
||||||
@@ -295,7 +295,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
final HandlingType downloadType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
|
final HandlingType downloadType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
|
||||||
final HandlingType updateType = calculateUpdateType(action, downloadType);
|
final HandlingType updateType = calculateUpdateType(action, downloadType);
|
||||||
|
|
||||||
final MaintenanceWindowStatus maintenanceWindow = calculateMaintenanceWindow(action);
|
final DdiMaintenanceWindowStatus maintenanceWindow = calculateMaintenanceWindow(action);
|
||||||
|
|
||||||
final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
|
final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
|
||||||
new DdiDeployment(downloadType, updateType, chunks, maintenanceWindow), actionHistory);
|
new DdiDeployment(downloadType, updateType, chunks, maintenanceWindow), actionHistory);
|
||||||
@@ -311,10 +311,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
return ResponseEntity.notFound().build();
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MaintenanceWindowStatus calculateMaintenanceWindow(final Action action) {
|
private static DdiMaintenanceWindowStatus calculateMaintenanceWindow(final Action action) {
|
||||||
if (action.hasMaintenanceSchedule()) {
|
if (action.hasMaintenanceSchedule()) {
|
||||||
return action.isMaintenanceWindowAvailable() ? MaintenanceWindowStatus.AVAILABLE
|
return action.isMaintenanceWindowAvailable() ? DdiMaintenanceWindowStatus.AVAILABLE
|
||||||
: MaintenanceWindowStatus.UNAVAILABLE;
|
: DdiMaintenanceWindowStatus.UNAVAILABLE;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -564,7 +564,8 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
mvc.perform(get("/{tenant}/controller/v1/1911/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
mvc.perform(get("/{tenant}/controller/v1/1911/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
||||||
action.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
action.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deployment.download", equalTo("forced")))
|
.andExpect(status().isOk()).andExpect(jsonPath("$.deployment.download", equalTo("forced")))
|
||||||
.andExpect(jsonPath("$.deployment.update", equalTo("skip")));
|
.andExpect(jsonPath("$.deployment.update", equalTo("skip")))
|
||||||
|
.andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("unavailable")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -583,6 +584,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
mvc.perform(get("/{tenant}/controller/v1/1911/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
mvc.perform(get("/{tenant}/controller/v1/1911/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
||||||
action.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
action.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deployment.download", equalTo("forced")))
|
.andExpect(status().isOk()).andExpect(jsonPath("$.deployment.download", equalTo("forced")))
|
||||||
.andExpect(jsonPath("$.deployment.update", equalTo("forced")));
|
.andExpect(jsonPath("$.deployment.update", equalTo("forced")))
|
||||||
|
.andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("available")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -79,8 +80,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
fileName = file.getOriginalFilename();
|
fileName = file.getOriginalFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try (InputStream in = file.getInputStream()) {
|
||||||
final Artifact result = artifactManagement.create(file.getInputStream(), softwareModuleId, fileName,
|
final Artifact result = artifactManagement.create(in, softwareModuleId, fileName,
|
||||||
md5Sum == null ? null : md5Sum.toLowerCase(), sha1Sum == null ? null : sha1Sum.toLowerCase(), false,
|
md5Sum == null ? null : md5Sum.toLowerCase(), sha1Sum == null ? null : sha1Sum.toLowerCase(), false,
|
||||||
file.getContentType());
|
file.getContentType());
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||||
@@ -60,10 +59,10 @@ import org.junit.Test;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
|
||||||
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
|
||||||
@@ -1227,9 +1226,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final Target target = testdataFactory.createTarget("fsdfsd");
|
final Target target = testdataFactory.createTarget("fsdfsd");
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
|
|
||||||
final String body = new JSONObject().put("id", set.getId()).put("type", "forced").put("maintenanceWindow",
|
final String body = new JSONObject().put("id", set.getId()).put("type", "forced")
|
||||||
AbstractIntegrationTest.getMaintenanceWindow(AbstractIntegrationTest.getTestSchedule(0), "", ""))
|
.put("maintenanceWindow", getMaintenanceWindow(getTestSchedule(0), "", "")).toString();
|
||||||
.toString();
|
|
||||||
|
|
||||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||||
.content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
.content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
@@ -1243,9 +1241,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final Target target = testdataFactory.createTarget("fsdfsd");
|
final Target target = testdataFactory.createTarget("fsdfsd");
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
|
|
||||||
final String body = new JSONObject().put("id", set.getId()).put("type", "forced").put("maintenanceWindow",
|
final String body = new JSONObject().put("id", set.getId()).put("type", "forced")
|
||||||
AbstractIntegrationTest.getMaintenanceWindow("", AbstractIntegrationTest.getTestDuration(10), ""))
|
.put("maintenanceWindow", getMaintenanceWindow("", getTestDuration(10), "")).toString();
|
||||||
.toString();
|
|
||||||
|
|
||||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||||
.content(body).contentType(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print())
|
.content(body).contentType(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print())
|
||||||
@@ -1261,8 +1258,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
|
|
||||||
final String body = new JSONObject().put("id", set.getId()).put("type", "forced").put("forcetime", "0")
|
final String body = new JSONObject().put("id", set.getId()).put("type", "forced").put("forcetime", "0")
|
||||||
.put("maintenanceWindow",
|
.put("maintenanceWindow",
|
||||||
AbstractIntegrationTest.getMaintenanceWindow(AbstractIntegrationTest.getTestSchedule(10),
|
getMaintenanceWindow(getTestSchedule(10), getTestDuration(10), getTestTimeZone()))
|
||||||
AbstractIntegrationTest.getTestDuration(10), AbstractIntegrationTest.getTestTimeZone()))
|
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||||
@@ -1277,11 +1273,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final Target target = testdataFactory.createTarget("fsdfsd");
|
final Target target = testdataFactory.createTarget("fsdfsd");
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
|
|
||||||
final String body = new JSONObject().put("id", set.getId()).put("type", "forced")
|
final String body = new JSONObject().put("id", set.getId()).put("type", "forced").put("maintenanceWindow",
|
||||||
.put("maintenanceWindow",
|
getMaintenanceWindow(getTestSchedule(-30), getTestDuration(5), getTestTimeZone())).toString();
|
||||||
AbstractIntegrationTest.getMaintenanceWindow(AbstractIntegrationTest.getTestSchedule(-30),
|
|
||||||
AbstractIntegrationTest.getTestDuration(5), AbstractIntegrationTest.getTestTimeZone()))
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||||
.content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
.content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distributionset_tag", indexes = {
|
@Table(name = "sp_distributionset_tag", indexes = {
|
||||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id"),
|
||||||
|
@Index(name = "sp_idx_distribution_set_tag_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_ds_tag"))
|
"name", "tenant" }, name = "uk_ds_tag"))
|
||||||
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
|
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target_tag", indexes = {
|
@Table(name = "sp_target_tag", indexes = { @Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id"),
|
||||||
@Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_target_tag_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
"name", "tenant" }, name = "uk_targ_tag"))
|
"name", "tenant" }, name = "uk_targ_tag"))
|
||||||
public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity {
|
public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE INDEX sp_idx_target_tag_01 ON sp_target_tag (tenant, name);
|
||||||
|
CREATE INDEX sp_idx_distribution_set_tag_01 ON sp_distributionset_tag (tenant, name);
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE INDEX sp_idx_target_tag_01 ON sp_target_tag (tenant, name);
|
||||||
|
CREATE INDEX sp_idx_distribution_set_tag_01 ON sp_distributionset_tag (tenant, name);
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE INDEX sp_idx_target_tag_01 ON sp_target_tag (tenant, name);
|
||||||
|
CREATE INDEX sp_idx_distribution_set_tag_01 ON sp_distributionset_tag (tenant, name);
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE INDEX sp_idx_target_tag_01 ON sp_target_tag (tenant, name);
|
||||||
|
CREATE INDEX sp_idx_distribution_set_tag_01 ON sp_distributionset_tag (tenant, name);
|
||||||
11
pom.xml
11
pom.xml
@@ -57,7 +57,7 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>Hudson</system>
|
<system>Jenkins</system>
|
||||||
<url>https://hudson.eclipse.org/hawkbit/</url>
|
<url>https://hudson.eclipse.org/hawkbit/</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
@@ -81,6 +81,15 @@
|
|||||||
<role>Committer</role>
|
<role>Committer</role>
|
||||||
</roles>
|
</roles>
|
||||||
</developer>
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>schabdo</id>
|
||||||
|
<email>Dominic.Schabel@bosch-si.com</email>
|
||||||
|
<organization>Bosch Software Innovations GmbH</organization>
|
||||||
|
<organizationUrl>https://www.bosch-si.com</organizationUrl>
|
||||||
|
<roles>
|
||||||
|
<role>Committer</role>
|
||||||
|
</roles>
|
||||||
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user