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

JBIDE-21720 Server Adapter: user choose default route when creating the server #1138

Closed
wants to merge 1 commit into from

Conversation

scabanovich
Copy link
Contributor

No description provided.

@scabanovich
Copy link
Contributor Author

scabanovich commented May 3, 2016

@adietish , please consider. I also have a doubt if in the same method service parameter taken as getService() is better than this.service, because if the model was initialized with a service before it was loaded, updating with getService() will remove the initial value.

@@ -472,7 +472,7 @@ public void setRoute(IRoute newRoute) {
this.deployProject, this.projects,
this.sourcePath, this.podPath, this.useInferredPodPath,
getService(), getServiceItems(),
route, this.selectDefaultRoute, this.routesByProject,
newRoute, this.selectDefaultRoute, this.routesByProject,
Copy link
Member

Choose a reason for hiding this comment

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

this is not enough. the newRoute is ignored in

protected IRoute updateRoute(IRoute route, List<IRoute> routes, IService service) {
        if (!isLoaded) {
            return null;
        }

        if (routes == null
                || routes.isEmpty()) {
            route = null;
        } else {
            route = ResourceUtils.getRouteForService(service, routes);
            if(route == null 
                    || !routes.contains(route)) {
                route = routes.get(0);
            }
        }
        firePropertyChange(PROPERTY_ROUTE, this.route, this.route = route);
        return this.route;
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice if such cases could be found by the compiler. A warning like "The passesd value of parameter 'route' is always reasigned before it is used" might help.
I did not add check ResourceUtils.areRelated(route, service) because list to select a route contains all project routes.

Copy link
Member

Choose a reason for hiding this comment

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

first thing to do in the method would be to

List<IRoute> matchingRoutes = ResourceUtils.getRoutesForService(service, routes);

then,

  • replace routes by matchingRoutes
  • remove route = ResourceUtils.getRouteForService(service, routes);

Copy link
Member

Choose a reason for hiding this comment

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

What would be nice is tests catching these errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is method updateRoutes() that is called before updateRoute(). The right place to narrow the list of routes is updateRoutes(). Now its implementation calls getAllRoutes(service) that returns all routes for the project. @adietish , could you please confirm if this logic is correct?

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 added test that for now checks the logic as is. We have to decide if the logic should be changed, then test may be updated to it.

Copy link
Member

Choose a reason for hiding this comment

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

currently writing tests for this model, and I also came across the fact that #getRoutes() returns all routes, while I keep wondering if we should only return the routes that match the currently selected service. getRoutes() is actually what the user gets as possible choices in the route combo. Does it makes sense that the user can choose whatever route he wants, even a route that's not related to the service that's currently selected?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's very strange that getRoutes() returns all routes, but it is just a model, and so it's not worth changing. I'd suggesting adding a new proper api method with javadoc that is getRoutesForService() with no argument, and possible a second with an IService attribute, which will return only the routes relevant to the selected (or passed in) service.

Copy link
Member

Choose a reason for hiding this comment

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

Does it makes sense that the user can choose whatever route he wants, even a route that's not related to the service that's currently selected?

No. I don't this makes much sense from my PoV but maybe I don't have the same domain knowledge you do. I personally can't think up an example where he'd want to use one service and an unrelated route. But then I don't know all the places the routes are used aside from show in web browser / welcome page / whatever it's called now.

@scabanovich scabanovich force-pushed the jbide-21720x branch 5 times, most recently from d25e0ad to 2e8f67b Compare May 9, 2016 14:01
@adietish
Copy link
Member

I am now merging this in after I have merged my tests & the change to the model which only returns the matching routes only (as discussed above): #1153

@adietish
Copy link
Member

thx! merged into #1156

@adietish adietish closed this May 12, 2016
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.

None yet

4 participants