This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
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 branch 'Demo_branch' into feature/DCMFOSS-70
- Loading branch information
Showing
42 changed files
with
1,065 additions
and
102 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...ctusx/demandcapacitymgmt/demandcapacitymgmtbackend/controllers/AddressBookController.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,68 @@ | ||
/* | ||
* ****************************************************************************** | ||
* 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.AddressBookApi; | ||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.AddressBookRequest; | ||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.AddressBookResponse; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.AllArgsConstructor; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.Role; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.AddressBookService; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
@RestController | ||
@AllArgsConstructor | ||
public class AddressBookController implements AddressBookApi { | ||
|
||
private final AddressBookService service; | ||
private HttpServletRequest request; | ||
|
||
@Override | ||
public ResponseEntity<Void> deleteAddressBook(AddressBookRequest addressBookRequest) throws Exception { | ||
if(UserUtil.getUserRole(request).equals(Role.ADMIN)){ | ||
service.deleteRecord(addressBookRequest); | ||
return ResponseEntity.status(201).build(); | ||
} | ||
return ResponseEntity.status(401).build(); | ||
|
||
} | ||
|
||
@Override | ||
public ResponseEntity<AddressBookResponse> getAddressBook(AddressBookRequest addressBookRequest) throws Exception { | ||
return ResponseEntity.status(200).body(service.getRecord(addressBookRequest)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<List<AddressBookResponse>> getAllAddressBooks() throws Exception { | ||
return ResponseEntity.status(200).body(service.getRecords()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<AddressBookResponse> postAddressBook(AddressBookRequest addressBookRequest) throws Exception { | ||
return ResponseEntity.status(200).body(service.postRecord(addressBookRequest)); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...pse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/controllers/UserController.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,24 @@ | ||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers; | ||
|
||
import eclipse.tractusx.demand_capacity_mgmt_specification.api.UserOperationsApi; | ||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.UserRequest; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.AllArgsConstructor; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.UserOperationsService; | ||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
public class UserController implements UserOperationsApi { | ||
|
||
private final UserOperationsService service; | ||
private HttpServletRequest request; | ||
|
||
@Override | ||
public ResponseEntity<Void> updateAnUser(UserRequest userRequest) throws Exception { | ||
service.updateUser(userRequest); | ||
return ResponseEntity.status(201).build(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...actusx/demandcapacitymgmt/demandcapacitymgmtbackend/entities/AddressBookRecordEntity.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,65 @@ | ||
/* | ||
* ****************************************************************************** | ||
* 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 jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
@Entity | ||
@Table(name = "address_book") | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AddressBookRecordEntity { | ||
|
||
@Id | ||
@GeneratedValue | ||
@Column(columnDefinition = "uuid", updatable = false, name = "id") | ||
private UUID id; | ||
|
||
@Column(name = "company_id") | ||
private UUID companyId; | ||
|
||
@Column(name = "name") | ||
private String name; | ||
|
||
@Column(name = "contact") | ||
private String contact; | ||
|
||
@Column(name = "email") | ||
private String email; | ||
|
||
@Column(name = "function") | ||
private String function; | ||
|
||
@Column(name = "picture") | ||
private byte[] picture; | ||
|
||
} |
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
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 |
---|---|---|
|
@@ -27,4 +27,5 @@ public enum FavoriteType { | |
COMPANY_BASE_DATA, | ||
MATERIAL_DEMAND, | ||
EVENT, | ||
ADDRESS_BOOK | ||
} |
35 changes: 35 additions & 0 deletions
35
...tusx/demandcapacitymgmt/demandcapacitymgmtbackend/repositories/AddressBookRepository.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,35 @@ | ||
/* | ||
* ******************************************************************************* | ||
* 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.repositories; | ||
|
||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.AddressBookRecordEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface AddressBookRepository extends JpaRepository<AddressBookRecordEntity, UUID> { | ||
List<AddressBookRecordEntity> findByNameOrCompanyId(@NonNull String name, @NonNull UUID companyId);} |
38 changes: 38 additions & 0 deletions
38
...se/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/AddressBookService.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,38 @@ | ||
/* | ||
* ****************************************************************************** | ||
* 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.services; | ||
|
||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.AddressBookRequest; | ||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.AddressBookResponse; | ||
|
||
import java.util.List; | ||
|
||
public interface AddressBookService { | ||
AddressBookResponse getRecord(AddressBookRequest request); | ||
|
||
List<AddressBookResponse> getRecords(); | ||
|
||
AddressBookResponse postRecord(AddressBookRequest request); | ||
|
||
void deleteRecord(AddressBookRequest request); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...e/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/GoldenRecordManager.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,31 @@ | ||
/* | ||
* ****************************************************************************** | ||
* 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.services; | ||
|
||
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.AddressBookRecordEntity; | ||
|
||
public interface GoldenRecordManager { | ||
AddressBookRecordEntity queryGoldenRecord(String recordQuery); | ||
|
||
AddressBookRecordEntity createRecord(String query); | ||
} |
7 changes: 7 additions & 0 deletions
7
...tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/UserOperationsService.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,7 @@ | ||
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services; | ||
|
||
import eclipse.tractusx.demand_capacity_mgmt_specification.model.UserRequest; | ||
|
||
public interface UserOperationsService { | ||
void updateUser(UserRequest request); | ||
} |
Oops, something went wrong.