-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from catenax-ng/feature/DCMFOSS-62-copy
Logging History service - 62
- Loading branch information
Showing
27 changed files
with
1,603 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...sx/demandcapacitymgmt/demandcapacitymgmtbackend/controllers/LoggingHistoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* ******************************************************************************* | ||
* Copyright (c) 2023 BMW AG | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* ******************************************************************************** | ||
*/ | ||
|
||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers; | ||
|
||
import eclipse.tractusx.demand_capacity_mgmt_specification.api.LoggingHistoryApi; | ||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*; | ||
import java.sql.Timestamp; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.LoggingHistoryService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
public class LoggingHistoryController implements LoggingHistoryApi { | ||
|
||
private final LoggingHistoryService loggingHistoryService; | ||
|
||
@Override | ||
public ResponseEntity<Void> createArchivedLog(LoggingHistoryRequest loggingHistoryRequest) { | ||
loggingHistoryService.archiveLog(loggingHistoryRequest); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<Void> deleteAllArchivedLogs() { | ||
loggingHistoryService.deleteAllArchivedLogs(); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<Void> deleteAllLogs() { | ||
loggingHistoryService.deleteAllLogs(); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<Void> deleteArchivedLogById(String logId) throws Exception { | ||
loggingHistoryService.deleteArchivedLogById(logId); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<Void> deleteLogById(String logId) throws Exception { | ||
loggingHistoryService.deleteLogById(logId); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<ArchivedLoggingHistoryResponse>> getArchivedLogs() throws Exception { | ||
return ResponseEntity.status(HttpStatus.OK).body(loggingHistoryService.getAllArchivedLogs()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<LoggingHistoryResponse>> filterLogs( | ||
String startTime, | ||
String endTime, | ||
String event, | ||
String materialDemandId, | ||
String capacityGroupId | ||
) throws Exception { | ||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(loggingHistoryService.filterLog(capacityGroupId, materialDemandId, event, startTime, endTime)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<LoggingHistoryResponse>> getLoggingHistory() { | ||
return ResponseEntity.status(HttpStatus.OK).body(loggingHistoryService.getAllLoggingHistory()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<LoggingHistoryResponse>> getLoggingHistoryForFavoriteCapacityGroups() { | ||
return ResponseEntity.status(HttpStatus.OK).body(loggingHistoryService.filterByFavoriteCapacityGroup()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<LoggingHistoryResponse>> getLoggingHistoryForFavoriteMaterialDemands() { | ||
return ResponseEntity.status(HttpStatus.OK).body(loggingHistoryService.filterByFavoriteMaterialDemand()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<LoggingHistoryResponse> postLogs(LoggingHistoryRequest loggingHistoryRequest) { | ||
LoggingHistoryResponse responseDto = loggingHistoryService.createLog(loggingHistoryRequest); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(responseDto); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...pse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/entities/ArchivedLogEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* ******************************************************************************* | ||
* Copyright (c) 2023 BMW AG | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* ******************************************************************************** | ||
*/ | ||
|
||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities; | ||
|
||
import io.micrometer.core.lang.Nullable; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.sql.Timestamp; | ||
import java.util.UUID; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventObjectType; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType; | ||
import org.hibernate.annotations.GenericGenerator; | ||
|
||
@Entity | ||
@Table(name = "archived_log") | ||
@Data | ||
@Builder | ||
public class ArchivedLogEntity { | ||
|
||
@Id | ||
@GenericGenerator(name = "uuid2", strategy = "uuid2") | ||
@Column(columnDefinition = "uuid", updatable = false, name = "id") | ||
private UUID id; | ||
|
||
@Column(name = "USER_ACCOUNT") | ||
private String userAccount; | ||
|
||
@Column(name = "TIME_CREATED") | ||
private Timestamp time_created; | ||
|
||
@Column(name = "EVENT_TYPE") | ||
private EventType eventType; | ||
|
||
@Column(columnDefinition = "uuid", updatable = false, name = "CAPACITY_GP_ID") | ||
@Nullable | ||
private UUID capacityGroupId; | ||
|
||
@Column(columnDefinition = "uuid", updatable = false, name = "MATERIAL_DEMAND_ID") | ||
@Nullable | ||
private UUID materialDemandId; | ||
|
||
@Column(name = "DESCRIPTION") | ||
private String description; | ||
|
||
@Column(name = "OBJECT_TYPE") | ||
private EventObjectType objectType; | ||
|
||
@Column(name = "IS_FAVORITED") | ||
private Boolean isFavorited; | ||
|
||
public ArchivedLogEntity( | ||
UUID id, | ||
String userAccount, | ||
Timestamp time_created, | ||
EventType eventType, | ||
UUID capacityGroupId, | ||
UUID materialDemandId, | ||
String description, | ||
EventObjectType objectType, | ||
Boolean isFavorited | ||
) { | ||
this.id = id; | ||
this.userAccount = userAccount; | ||
this.time_created = time_created; | ||
this.eventType = eventType; | ||
this.capacityGroupId = capacityGroupId; | ||
this.materialDemandId = materialDemandId; | ||
this.description = description; | ||
this.objectType = objectType; | ||
this.isFavorited = isFavorited; | ||
} | ||
|
||
public ArchivedLogEntity() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
.../tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/entities/LoggingHistoryEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* ******************************************************************************* | ||
* Copyright (c) 2023 BMW AG | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* ******************************************************************************** | ||
*/ | ||
|
||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities; | ||
|
||
import io.micrometer.core.lang.Nullable; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.sql.Timestamp; | ||
import java.util.UUID; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventObjectType; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventStatus; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.UserSpecificEventStatus; | ||
import org.hibernate.annotations.GenericGenerator; | ||
|
||
@Entity | ||
@Table(name = "logging_history") | ||
@Data | ||
@Builder | ||
public class LoggingHistoryEntity { | ||
|
||
@Id | ||
@GenericGenerator(name = "uuid2", strategy = "uuid2") | ||
@Column(columnDefinition = "uuid", updatable = false, name = "id") | ||
private UUID id; | ||
|
||
@Column(name = "USER_ACCOUNT") | ||
@Nullable | ||
private String userAccount; | ||
|
||
@Column(name = "TIME_CREATED") | ||
@Nullable | ||
private Timestamp time_created; | ||
|
||
@Column(name = "EVENT_TYPE") | ||
@Nullable | ||
private EventType eventType; | ||
|
||
@Column(columnDefinition = "uuid", updatable = false, name = "CAPACITY_GP_ID") | ||
@Nullable | ||
private UUID capacityGroupId; | ||
|
||
@Column(columnDefinition = "uuid", updatable = false, name = "MATERIAL_DEMAND_ID") | ||
@Nullable | ||
private UUID materialDemandId; | ||
|
||
@Nullable | ||
@Column(name = "DESCRIPTION") | ||
private String description; | ||
|
||
@Nullable | ||
@Column(name = "OBJECT_TYPE") | ||
private EventObjectType objectType; | ||
|
||
@Column(name = "IS_FAVORITED") | ||
@Nullable | ||
private Boolean isFavorited; | ||
|
||
public LoggingHistoryEntity( | ||
UUID id, | ||
String userAccount, | ||
Timestamp time_created, | ||
EventType eventType, | ||
UUID capacityGroupId, | ||
UUID materialDemandId, | ||
String description, | ||
EventObjectType objectType, | ||
Boolean isFavorited | ||
) { | ||
this.id = id; | ||
this.userAccount = userAccount; | ||
this.time_created = time_created; | ||
this.eventType = eventType; | ||
this.capacityGroupId = capacityGroupId; | ||
this.materialDemandId = materialDemandId; | ||
this.description = description; | ||
this.objectType = objectType; | ||
this.isFavorited = isFavorited; | ||
} | ||
|
||
public LoggingHistoryEntity() {} | ||
} |
33 changes: 33 additions & 0 deletions
33
...tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/entities/enums/EventObjectType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* ******************************************************************************* | ||
* Copyright (c) 2023 BMW AG | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* ******************************************************************************** | ||
*/ | ||
|
||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums; | ||
|
||
public enum EventObjectType { | ||
MATERIAL_DEMAND, | ||
CAPACITY_GROUP, | ||
DEMAND_CATEGORY, | ||
COMPANY, | ||
WEEKLY_MATERIAL_DEMAND, | ||
WEEKLY_BASED_CAPACITY_GROUP, | ||
LINK_DEMAND_SERVICE, | ||
} |
Oops, something went wrong.