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

Add Ladder Map Voting stuff #60

Merged
merged 4 commits into from
Sep 23, 2018
Merged

Add Ladder Map Voting stuff #60

merged 4 commits into from
Sep 23, 2018

Conversation

1-alex98
Copy link
Member

@1-alex98 1-alex98 commented Sep 6, 2018

Fixes #52

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 6, 2018

Attention Voting is partly broken !!! on current devlop of java-api. I made the necessary change and will reference the other PR soon. Due to changes made lately

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 6, 2018

image

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 8, 2018

depends on
FAForever/faf-java-api#250

Copy link
Member

@Brutus5000 Brutus5000 left a comment

Choose a reason for hiding this comment

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

Shame on me. I wasn't aware I broke develop. Will add a build pipeline to prevent this in the future.

For now I just reviewed the code itself and did not actually test the functionality.

result.remove(map);
}
}
log.trace("found {} maps", preResult.size());
Copy link
Member

@Brutus5000 Brutus5000 Sep 9, 2018

Choose a reason for hiding this comment

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

What are you trying to achieve here? If this is about erasing duplicates then put it into a Set<Map> outside of the method or in a new method. We are using the id of all elide entities to check for equality.
Furthermore: You are changing the semantics of this method, which will break other parts of the ui. Assume someone assigns different versions of the same map to a pool. You will never be able to fix this if you prematurely remove the duplicates. It may have been a mistake to return the Map instead of the MapVersion here, because this is ambigious. We could fix that instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. The Set
    As you set I use the id instead of equals because equal method won't work here, I check that. We
    might wanna change that as well.
  2. Returning Map instead of MapVersion
    I changed it because of problems that were there. You add one map version, the map was added with all its versions and version that were not included were shown empty. And if you added two versions of the same map the map was shown twice. So I corrected all those fallacies. I only show versions that are in the ladder map pool and I don't show map duplicates any longer. From the way the tree view is structured it needs Map objects and also I did not change the return type I only corrected the data output of the method.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I should change anything here should I?

Copy link
Member

Choose a reason for hiding this comment

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

This test shows me that equality is checked by id only:

    @Test
    public void checkEqualityOfMapById() {
        MapVersion m1 = (MapVersion)new MapVersion()
                .setRanked(true)
                .setId("1");

        MapVersion m1_copy = (MapVersion)new MapVersion()
                .setRanked(false)
                .setId("1");

        assertTrue(Objects.equals(m1, m1_copy));
        assertFalse(m1 == m1_copy);
    }

A set has to work. The above code needs to be simplified.

Copy link
Member Author

Choose a reason for hiding this comment

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

What you are looking at it the MapVersion equal code which is not relevant because it is a Set, the correct code is:



    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Map)) {
            return false;
        } else {
            Map other = (Map)o;
            return other.canEqual(this);
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Map;
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

Shall I change faf-commons????

Copy link
Member

Choose a reason for hiding this comment

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

Oh that was due to some Lombok annotation leftovers. Fixed in FAForever/faf-java-commons@6623f1f

List<Message> messages = fafApi.getAll(ElideNavigator.of(Message.class).collection()
.addFilter(ElideNavigator.qBuilder().string("region").eq(message.getRegion()))
.addFilter(ElideNavigator.qBuilder().string("language").eq(message.getLanguage()))
.addFilter(ElideNavigator.qBuilder().string("key").eq(message.getKey())));
Copy link
Member

Choose a reason for hiding this comment

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

My bad. This should not be addFilter, but setFilter instead in the ElideNavigator. You can't add multiple filters, each one will override the previous.
Use the qBuilders .and() concatenation instead.

@@ -117,7 +120,7 @@ public VotingQuestion create(VotingQuestion votingQuestion) {
//region choices
public List<VotingChoice> getAllChoicesFromApi() {
log.debug("Retrieving all choices");
List<VotingChoice> result = fafApi.getAll(ElideNavigator.of(VotingChoice.class).collection());
List<VotingChoice> result = fafApi.getAll(ElideNavigator.of(VotingChoice.class).collection().addIncludeOnCollection("votingQuestion"));
Copy link
Member

Choose a reason for hiding this comment

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

Please follow the style as in line 79: if there are more operations put them in new lines.

@@ -1093,7 +1092,7 @@ public static void buildMessagesTable(TableView<MessageFx> messageTableView, Mes
messageTableView.setEditable(true);
HashMap<TableColumn<MessageFx, ?>, Function<MessageFx, ?>> extractors = new HashMap<>();

TableColumn<MessageFx, Number> idColumn = new TableColumn<>("ID");
TableColumn<MessageFx, Integer> idColumn = new TableColumn<>("ID");
Copy link
Member

Choose a reason for hiding this comment

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

Please stick with number. There are some limitations in JavaFX where you get weird errors if you use Integer. I don't recall what is was but it is hard to track.


try {
if (votingService.create(votingSubjectFX) == null) {
if (votingService.create(votingSubject) == null) {
Copy link
Member

Choose a reason for hiding this comment

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

We are separating the api entities from the fx beans on purpose. There is a strict separation between API dtos and our UI entities. Revert these changes.

votingService.updateSubject(selectedItem);
votingSubject.setId(selectedItem.getId());
votingSubject.setRevealWinner(true);
votingService.update(votingSubject);
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Stick with the FX beans in the controllers.

}
if (!messages.isEmpty()) {
log.info("deleting existing message ''{}''", message);
messages.forEach(message1 -> deleteMessage(messagesMapper.map(message1)));
Copy link
Member

Choose a reason for hiding this comment

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

Please us a proper variable name instead of message1

@1-alex98 1-alex98 force-pushed the feature/#52-ladder-vote branch 2 times, most recently from 295d742 to fa8dc78 Compare September 11, 2018 20:52
Set<Map> result = ladder1v1MapVersions.stream()
.map(mapVersion -> {
Map map = mapVersion.getMap();
map.setVersions(map.getVersions().stream().filter(ladder1v1MapVersions::contains).collect(Collectors.toList()));
Copy link
Member

@Brutus5000 Brutus5000 Sep 11, 2018

Choose a reason for hiding this comment

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

Proper formatting now and we're good.

@1-alex98
Copy link
Member Author

like this

@Brutus5000
Copy link
Member

Should this work against develop-api? Creating a vote fails with an error without using the regular exception message bo and then it throws a success message afterwards. Both needs to be fixed.

@1-alex98
Copy link
Member Author

As I wrote early no it does not work against develop api

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 12, 2018

depends on
FAForever/faf-java-api#250

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 12, 2018

fixed that false positive dialog. was missing a return in error case;)

@@ -84,6 +83,8 @@ public FafApiCommunicationService(ResourceConverter resourceConverter, Applicati
.additionalMessageConverters(jsonApiMessageConverter)
.errorHandler(jsonApiErrorHandler)
.rootUri(apiBaseUrl);
headers = new HttpHeaders();
Copy link
Member Author

Choose a reason for hiding this comment

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

@bukajsytlos @Brutus5000 for post i got headers working, however i still need to due it for patch. Do you know if there is a way to set headers in general?

try {
authorizedLatch.await();
return restOperations.exchange(url, HttpMethod.PATCH, new HttpEntity<>(object), routeBuilder.getDtoClass()).getBody();
return restOperations.exchange(url, HttpMethod.PATCH, new HttpEntity<>(object, httpHeaders), routeBuilder.getDtoClass()).getBody();
} catch (Throwable t) {
applicationEventPublisher.publishEvent(new FafApiFailModifyEvent(t, routeBuilder.getDtoClass(), url));
throw t;
Copy link
Member Author

Choose a reason for hiding this comment

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

How do i do it for the patch method blow @bukajsytlos @Brutus5000

@1-alex98
Copy link
Member Author

The changes you made do not work @Brutus5000

2018-09-22 20:27:07.396  WARN 520912 --- [tp2074687317-93] c.f.a.e.GlobalControllerExceptionHandler : Internal server error

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
	at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:216)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:376)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:316)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:62)
	at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:350)
	at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1188)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:964)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:215)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:531)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
	at java.lang.Thread.run(Thread.java:748)

@1-alex98
Copy link
Member Author

1-alex98 commented Sep 22, 2018

I would suspect it is because you only set the content type but not what it consumes 🤔

@1-alex98
Copy link
Member Author

 @throws HttpMediaTypeNotAcceptableException if there are matches by URL
	 * but not by consumable/producible media types

@1-alex98
Copy link
Member Author

image
image
Everything matches I dont get it. @bukajsytlos got an idea?

@1-alex98
Copy link
Member Author

Works when I do this
image

@Brutus5000
Copy link
Member

When do you run into the error? Is the stacktrace API or client?

@1-alex98
Copy link
Member Author

API stacktrace

@1-alex98
Copy link
Member Author

I think your changes are good @bukajsytlos I will test it

@1-alex98
Copy link
Member Author

Works fine however ladder vote broke but i am sure i can quickly fix that

@1-alex98
Copy link
Member Author

All good to go and finally working again

Copy link
Member

@Brutus5000 Brutus5000 left a comment

Choose a reason for hiding this comment

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

Finally. Let's see which surprises production will bring us :D

@Brutus5000 Brutus5000 merged commit ff246a3 into develop Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants