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

Select apps in group edit analysis page T517 #225

Merged

Conversation

OndraZizka
Copy link
Contributor

@OndraZizka OndraZizka commented Feb 23, 2017

No description provided.

@jsight
Copy link
Member

jsight commented Feb 23, 2017

This needs to be deferred, as the data model is likely to change completely. T517 is not in the current sprint, afaik?

Copy link
Collaborator

@klinki klinki left a comment

Choose a reason for hiding this comment

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

I left you there couple of comments.

{
return this.registeredApplicationService.getAllApplications();
if (projectId == null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like that. MigrationProject entity has applications collection so we can load then with project.
Or add new endpoint getProjectApplications. IMHO getAllApplications should always return all applications and remain parameterless. And this endpoint is not even used in the application, I think we use it only in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"MigrationProject entity has applications collection" - well, it has. But jpamodelgen strips relations away.

Regarding new endpoint resource - that was my first idea too. But the way the subpaths were created, it's not possible - / is used and /{*} is used. Only after that I found I can use regex in the URL, so that could be the solution. When we get back to this task.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think putting it in here is ok, but it probably should be something like getApplicationsByProject, instead of overriding "getAllApplications".

The other paths are used, but they could be changed. :)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you would even need to change the others, actually. Why not just "/by-project-id/{id}"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Path of least resistance. If I changed other paths, I would have to go through all components and search where the path is used. Since we don't use a single constant and build them by concatenation, this seemed easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, I am for such path, perhaps shorter one, like, .../id-{id}. It's only it was already this way. Maybe we could have a guide on how to do the endpoint URLs.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that I understand your point there. It seems like each endpoint has a single client service and that service does generally use constants.

@@ -64,6 +65,9 @@ export class MigrationProjectService extends AbstractService {
get(id: number) {
let headers = new Headers();
let options = new RequestOptions({ headers: headers });
if (!isNumber(id)) {
throw new Error("Not an app ID: " + id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nope, it is not an app id. It should be project id.
But 👍 for adding parameter validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You got me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE

@@ -40,6 +42,7 @@
public static final String REGISTERED_APPLICATION_ID = "registered_application_id";

@Id
@Access(AccessType.PROPERTY) // Allow accessing ID without Lazy-loading the entity.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this work? Does it mean you can load collection of RegisteredApplications and if you access only ID, it will create SQL query getting only ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have a relation to this, the ID is in the source entity table. And the proxy returns that id. So Hibernate doesn't need to load anything, it's just there.

this.dummyProject = this.dataProvider.getMigrationProject();
}

@Test
@RunAsClient
public void testRegisterAppFromProject() throws Exception
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this test do anything we don't have covered already?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see it now. It is wrongly named test. It should not test registering applications, but rather getAllApplications endpoint with projectId parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it should be named testRegisteredAppFromProject(). I don't like the name RegisteredApplication, too long and not much meaningful. I'd rather name the other one UserApplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE

@@ -16,8 +17,8 @@ <h2 *ngIf="!applicationGroup" i18n>Loading...</h2>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-2 control-label" for="migrationPath" i18n>Migration Path</label>
<div class="col-md-6">
<label class="col-md-2 control-label" for="migrationPath" i18n>Migration Scenario</label>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We agreed we will stick to Migration Path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgotten bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE

<button [disabled]="!analysisContextForm.form.valid" class="btn btn-primary" (click)="save()" i18n>Save Configuration</button>
<button (click)="cancel()" type="button" class="btn btn-default" i18n>Cancel</button>
<div class="col-lg-10 col-lg-offset-2">
<button (click)="saveAndRun()" class="btn btn-primary" [disabled]="!analysisContextForm.form.valid" *ngIf="isInWizard" i18n>Save &amp; Run</button>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this change good for? It just reorders things...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes the source more readable - attributes are in the same order.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's questionable because you moved *ngIf part to the end so it will take you more time to figure out when it is visible.
But we don't really have any convention on this, so if you think it is better...


private _migrationPathsObservable:Observable<MigrationPath[]>;
private _migrationPathsObservable: Observable<MigrationPath[]>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you do those formatting changes at least in different commit, if not in different PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but then I wouldn't probably get to it ever.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok. At least try to make it in different commit next time :)

Btw maybe we could define some code formatting rules and run some automatic reformatting on all files? (when changes settle down little bit, so we don't have tons of conflicts)

Copy link
Member

Choose a reason for hiding this comment

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

@klinki - I would love to have a code formatter that we could all consistently use. We all use different IDEs, though, I think, so that might be a little harder. It would probably have to be an external tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm on IDEA now, what do you use?
Also, +1 to formatter if it doesn't control everything, like the one we have for Java. Sometimes the default is not the best, especially for the condensed syntax of TS.

Copy link
Member

Choose a reason for hiding this comment

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

I am on IDEA as well, but I don't think that everyone is. And, I think it would be a good idea to avoid tying to a single IDE anyway.

saveAndRun() {
this.action = Action.SaveAndRun;
}
save() {
this.action = Action.Save;
}
cancel() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any need of this reordering.

@OndraZizka
Copy link
Contributor Author

I suggest we merge this (when ok to), because the data layer change won't change much in this PR - just the service and the checked values mapping.

@OndraZizka
Copy link
Contributor Author

I am not sure how to rebase this, standard rebase fails. Maybe by doing a diff and applying that?

@OndraZizka OndraZizka force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch from 0e59d7c to 657bbc4 Compare February 28, 2017 17:14
@OndraZizka
Copy link
Contributor Author

I have done basically that - detaching, git reset master, git commit --all

@klinki
Copy link
Collaborator

klinki commented Mar 1, 2017

Why did standard rebase fail?

@OndraZizka OndraZizka force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch 2 times, most recently from 0e59d7c to 1875f31 Compare March 2, 2017 15:47
@OndraZizka
Copy link
Contributor Author

It was a weird rebase, I ended up with master merged into my branch, and then I couldn't push it to my github repo, kept refusing... so I did what I wrote above, and lost those 2 files for some reason

@jsight
Copy link
Member

jsight commented Mar 2, 2017

retest

@jsight
Copy link
Member

jsight commented Mar 2, 2017

I think some of the merges have broken this. Just a few things that I noticed:

  • The path for getting applications is not being generated correctly. I fixed that locally.
  • AAA appears before each selection item
  • The selections don't appear to actually affect the analysis runs
  • Frequently, I get errors like "Already had POJO for id (java.lang.Long) [com.fasterxml.jackson.annotation.ObjectIdGenerator$IdKey@4fb09ae7]" when trying to save the configuration.

@klinki
Copy link
Collaborator

klinki commented Mar 2, 2017

I will look at it tomorrow and fix it.

@OndraZizka
Copy link
Contributor Author

I forgot I left it in half-done state, only the UI + storing.

@OndraZizka OndraZizka force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch 2 times, most recently from e3d9fec to c840aad Compare March 3, 2017 01:47
@OndraZizka
Copy link
Contributor Author

OndraZizka commented Mar 3, 2017

  • "The path for getting applications is not being generated correctly. I fixed that locally." - not sure what that means.
  • AAA removed
  • "The selections don't appear to actually affect the analysis runs" - I assumed that setting the apps that belong to the group should be enough. Doesn't the launcher take app list from the DB?
  • "Already had POJO" - yeah I was solving this for a while but then you said that's not something we should be solving now. I understood it related to this issue. Maybe it was to the task as a whole? :)

@klinki klinki force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch from 8167859 to f522bad Compare March 3, 2017 12:13
@klinki
Copy link
Collaborator

klinki commented Mar 3, 2017

That path thing was my fault, sorry. I fixed that.

@klinki
Copy link
Collaborator

klinki commented Mar 3, 2017

retest

@klinki
Copy link
Collaborator

klinki commented Mar 3, 2017

  • for some reason it calls method shouldBeChecked every few seconds
  • it allows to submit form without any application selected
  • those issues with POJOs make it unusable
  • it feels we really should merge entities AnalysisContext and ApplicationGroup first, because in cause of one of updates fails, you get into inconsistent state (this actually happens right now, AnalysisContext update will proceed successfully, but ApplicationGroup returns error 500).

@klinki klinki force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch from adf3754 to dd1d394 Compare March 3, 2017 14:41
@klinki klinki force-pushed the selectAppsInGroup-editAnalysisPage-T517 branch from dd1d394 to 2d02e92 Compare March 3, 2017 14:41
Copy link
Collaborator

@klinki klinki left a comment

Choose a reason for hiding this comment

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

Even though I think there are still some minor issues, I'm for merging.

All those major issues should be resolved. I just tested it and now it successfully updates the group and it actually changes the analyzed applications so it seems to be working.

@OndraZizka
Copy link
Contributor Author

IMO the POJO issue should be solved at the server. The server service should be able to accept the real data. It doesn't matter in our current situation, but imagine we have 10 different clients. Each client will have to strip the object before sending to the service.

@OndraZizka
Copy link
Contributor Author

"for some reason it calls method shouldBeChecked every few seconds" - that's not a problem of this PR but of the whole app - it's being re-rendered repeatedly. We need to find out why.

@klinki
Copy link
Collaborator

klinki commented Mar 3, 2017

@OndraZizka Well, for the first item there is much, much more work to be done, if we want to support different clients in the future. And that POJO issue is IMHO caused by RestEasy and @JsonIdentityInfo annotation. (Which I'm really not a big fan of, since it can cause unpredictable outputs). But that's a whole different story for different PR.

@jsight
Copy link
Member

jsight commented Mar 3, 2017

It would be nice if we had a client library that could deal with cycles properly. I'm sure some of these must exist.

@OndraZizka
Copy link
Contributor Author

How was the "The selections don't appear to actually affect the analysis runs" solved?

@OndraZizka
Copy link
Contributor Author

@klinki The point was not having multiple clients. The point was that this way of doing REST api creates a burden of extra handling on the client side at each place where it is used.

@OndraZizka OndraZizka merged commit 0f8dac8 into windup:master Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants