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

WFPREV-127 Add activity endpoints #468

Merged
merged 24 commits into from
Jan 31, 2025
Merged

WFPREV-127 Add activity endpoints #468

merged 24 commits into from
Jan 31, 2025

Conversation

ssylver93
Copy link
Collaborator

No description provided.

@ssylver93 ssylver93 requested review from yzlucas and dhlevi January 30, 2025 02:36
private String activityDescription;

@NotNull
@Column(name = "activity_start_date")
Copy link
Collaborator

@yzlucas yzlucas Jan 30, 2025

Choose a reason for hiding this comment

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

I think activity_start_date, and activity_end_date are mandatory field, not nullable in database schema?

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, done

@yzlucas
Copy link
Collaborator

yzlucas commented Jan 30, 2025

Looks good. Had some question around nullable thing, please feel free to resolve conversation once confirm.
I assume the postman script and GraalVm config will be added?

@ssylver93
Copy link
Collaborator Author

Looks good. Had some question around nullable thing, please feel free to resolve conversation once confirm. I assume the postman script and GraalVm config will be added?

@yzlucas yeah I need to add Postman and GraalVM config, I'll add them with my commit for the nullable = false attributes

private String activityName;

@NotNull
@Column(name = "activity_description", length = 4000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please also add this as nullable = false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, done

private UUID activityFundingSourceGuid;

@NotNull
@Column(name = "activity_name", length = 4000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, done

dhlevi
dhlevi previously approved these changes Jan 30, 2025
Copy link
Contributor

@dhlevi dhlevi left a comment

Choose a reason for hiding this comment

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

Are you missing configurations for GraalVM?

try {
// Verify project fiscal exists and belongs to project
ProjectFiscalEntity projectFiscal = projectFiscalRepository.findById(UUID.fromString(fiscalGuid))
.orElseThrow(() -> new EntityNotFoundException(FISCAL_NOT_FOUND + fiscalGuid));
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use MessageFormat.format("{0}: {1}", FISCAL_NOT_FOUND, fiscalGuid);
So you don't need to add the Colon and Space to the constant string. Same for other spots. Optional of course, what's here is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good tip, I've updated now

public void assignAssociatedEntities(ActivityModel resource, ActivityEntity entity) {
if (resource.getActivityStatusCode() != null) {
String forestAreaCode1 = resource.getActivityStatusCode().getActivityStatusCode();
ActivityStatusCodeEntity activityStatusCode = loadActivityStatusCode(forestAreaCode1);
Copy link
Contributor

Choose a reason for hiding this comment

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

You're only calling the load<code> methods in this one spot. Why have them in their own methods? You can just use the code directly here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to access the code directly

public ActivityStatusCodeEntity loadActivityStatusCode(String activityStatusCode) {
return activityStatusCodeRepository
.findById(activityStatusCode)
.orElseThrow(() -> new IllegalArgumentException("ActivityStatusCode not found: " + activityStatusCode));
Copy link
Contributor

Choose a reason for hiding this comment

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

You're calling "or else throw" but the thrown error is never handled anywhere up the chain. Are we assuming this is just a global throw that should fail the whole process?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Catch statements added to ActivityController

activityRepository.deleteById(UUID.fromString(activityGuid));
}

public void assignAssociatedEntities(ActivityModel resource, ActivityEntity entity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Binding these codes to objects from resource to entity should be handled by hibernate already. Thats what the @ManyToOne(fetch = FetchType.EAGER, optional = true) bits are doing. Why are we manually applying them here from the same value? What am I missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think assigning them manually is needed as when I break at line 197, the code models do not have each field populated, just their relevant code string
image
When these codes do not get manually assigned the insert gives the error org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : ca.bc.gov.nrs.wfprev.data.entities.ActivityEntity.activityStatusCode -> ca.bc.gov.nrs.wfprev.data.entities.ActivityStatusCodeEntity

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. This will be an issue with the relationship fetch/cascade rules. We can look into that later

@dhlevi
Copy link
Contributor

dhlevi commented Jan 30, 2025

Are you missing configurations for GraalVM?

I see Lucas mentioned above and you replied that it's coming, so ignore this comment!

@yzlucas yzlucas self-requested a review January 30, 2025 23:00
@ssylver93 ssylver93 merged commit fa25b3d into main Jan 31, 2025
7 checks passed
@ssylver93 ssylver93 deleted the feature/WFPREV-127 branch January 31, 2025 00:21
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.

3 participants