Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufal/be-collection2item-table-is-not-migrated #439

Merged

Conversation

milanmajchrak
Copy link
Collaborator

@milanmajchrak milanmajchrak commented Sep 21, 2023

Phases MP MM MB MR JM Total
ETA 0 0 0 0 0 0
Developing 0 6 0 0 0 0
Review 0 0 0 0 0 0
Total - - - - - 0
ETA est. 0
ETA cust. - - - - - 0

Problem description

I have a big problem with parsing Content-Type: 'text-uri', because it cannot recognize new line string \n passed from Python. I wanted to use Vanilla endpoint "/api/core/items/{ITEM_UUI}/mappedCollections/" at first, but after a few hours of failing I decided to create a new one /api/clarin/import/item/{ITEM_UUID}/mappedCollections.

@milanmajchrak milanmajchrak changed the title Ufal/be collection2item table is not migrated ufal/be-collection2item-table-is-not-migrated Sep 21, 2023
@milanmajchrak milanmajchrak self-assigned this Sep 21, 2023
try {
Object obj = parser.parse(new InputStreamReader(request.getInputStream()));

for (Object entity : (JSONArray) obj) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I will add some control if obj is JSONArray

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check added

throw new RuntimeException("Context is null - cannot import item's mapped collections.");
}

// Load List of collection self links
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean single collection? If not, use collections

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not I think more collections, not one

List<DSpaceObject> listDsoFoundInRequest
= utils.constructDSpaceObjectList(context, requestAsStringList);

if (listDsoFoundInRequest.size() < 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use const for 1, but as you want

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used CollectionUtils.isEmpty(listDsoFoundInRequest) instead


private boolean checkIfOwningCollection(Item item, UUID collectionID) {
return item.getOwningCollection().getID().equals(collectionID);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure that item has collection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a check

// It is owning collection
String col1SelfLink = "https://localhost:8080/spring-rest/api/core/collections/" + col1.getID();
String col2SelfLink = "https://localhost:8080/spring-rest/api/core/collections/" + col2.getID();
String col3SelfLink = "https://localhost:8080/spring-rest/api/core/collections/" + col3.getID();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use const for common parts of links

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@milanmajchrak milanmajchrak merged commit aa6c260 into dtq-dev Oct 3, 2023
3 of 4 checks passed
milanmajchrak added a commit that referenced this pull request Jun 19, 2024
* Created endpoint for importing item's mapped collections and created test for it

* Fixed checkstyle issues

* Fixed conflicts

* refactoring

* Refactoring according to request changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UFAL/PY-collection2item table is not migrated
2 participants