mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 14:57:12 +00:00
sovled master merge conflicts in dashboards EventLogo
This commit is contained in:
commit
79aeb1c8a6
175 files changed
+7566
-3882
No files matched your search
@@ -1,64 +1,49 @@
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sse.common.media.ImageSize;
|
||||
|
||||
/**
|
||||
* An event is a group of {@link Regatta regattas} carried out at a common venue within a common time frame. For
|
||||
* example, Kiel Week 2011 is an event, and the International German Championship 2011 held, e.g., in Travem�nde, is an event,
|
||||
* too.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public interface Event extends EventBase {
|
||||
Iterable<Regatta> getRegattas();
|
||||
|
||||
void addRegatta(Regatta regatta);
|
||||
|
||||
void removeRegatta(Regatta regatta);
|
||||
|
||||
/**
|
||||
* For events, the ID is always a UUID.
|
||||
*/
|
||||
UUID getId();
|
||||
|
||||
/**
|
||||
* Returns a non-<code>null</code> live but unmodifiable collection of leaderboard groups that were previously
|
||||
* {@link #addLeaderboardGroup(LeaderboardGroup) added} to this event, in the order of their addition. Therefore, to
|
||||
* change the iteration order, {@link #removeLeaderboardGroup(LeaderboardGroup)} and
|
||||
* {@link #addLeaderboardGroup(LeaderboardGroup)} need to be used.
|
||||
*/
|
||||
@Override
|
||||
Iterable<LeaderboardGroup> getLeaderboardGroups();
|
||||
|
||||
void addLeaderboardGroup(LeaderboardGroup leaderboardGroup);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if and only if a leaderboard group equal to <code>leaderboardGroup</code> was part of
|
||||
* {@link #getLeaderboardGroups()} and therefore was actually removed
|
||||
*/
|
||||
boolean removeLeaderboardGroup(LeaderboardGroup leaderboardGroup);
|
||||
|
||||
/**
|
||||
* Replaces the {@link #getLeaderboardGroups() current contents of the leaderboard groups sequence} by the
|
||||
* leaderboard groups in <code>leaderboardGroups</code>.
|
||||
*/
|
||||
void setLeaderboardGroups(Iterable<LeaderboardGroup> leaderboardGroups);
|
||||
|
||||
/**
|
||||
* For the images references by the image URLs in {@link #getImageURLs()}, {@link #getSponsorImageURLs()} and {@link #getLogoImageURL()}
|
||||
* determines the image dimensions. The retrieval of the image size is started when the URL is added to this event, and the result is
|
||||
* cached. Should the image change its size afterwards or change its availability status, this event won't notice unless the image is
|
||||
* removed from this event and added again.<p>
|
||||
*
|
||||
* Note that exceptions may result should the image be unavailable. If the image URL leads to a document that is not an image,
|
||||
* <code>null</code> will result.
|
||||
*/
|
||||
ImageSize getImageSize(URL imageURL) throws InterruptedException, ExecutionException;
|
||||
|
||||
}
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
|
||||
/**
|
||||
* An event is a group of {@link Regatta regattas} carried out at a common venue within a common time frame. For
|
||||
* example, Kiel Week 2011 is an event, and the International German Championship 2011 held, e.g., in Travem�nde, is an event,
|
||||
* too.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public interface Event extends EventBase {
|
||||
Iterable<Regatta> getRegattas();
|
||||
|
||||
void addRegatta(Regatta regatta);
|
||||
|
||||
void removeRegatta(Regatta regatta);
|
||||
|
||||
/**
|
||||
* For events, the ID is always a UUID.
|
||||
*/
|
||||
UUID getId();
|
||||
|
||||
/**
|
||||
* Returns a non-<code>null</code> live but unmodifiable collection of leaderboard groups that were previously
|
||||
* {@link #addLeaderboardGroup(LeaderboardGroup) added} to this event, in the order of their addition. Therefore, to
|
||||
* change the iteration order, {@link #removeLeaderboardGroup(LeaderboardGroup)} and
|
||||
* {@link #addLeaderboardGroup(LeaderboardGroup)} need to be used.
|
||||
*/
|
||||
@Override
|
||||
Iterable<LeaderboardGroup> getLeaderboardGroups();
|
||||
|
||||
void addLeaderboardGroup(LeaderboardGroup leaderboardGroup);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if and only if a leaderboard group equal to <code>leaderboardGroup</code> was part of
|
||||
* {@link #getLeaderboardGroups()} and therefore was actually removed
|
||||
*/
|
||||
boolean removeLeaderboardGroup(LeaderboardGroup leaderboardGroup);
|
||||
|
||||
/**
|
||||
* Replaces the {@link #getLeaderboardGroups() current contents of the leaderboard groups sequence} by the
|
||||
* leaderboard groups in <code>leaderboardGroups</code>.
|
||||
*/
|
||||
void setLeaderboardGroups(Iterable<LeaderboardGroup> leaderboardGroups);
|
||||
}
|
||||
@@ -2,47 +2,26 @@ package com.sap.sailing.domain.base.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.base.Venue;
|
||||
import com.sap.sailing.domain.common.impl.ImageSizeImpl;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.media.ImageSize;
|
||||
|
||||
public class EventImpl extends EventBaseImpl implements Event {
|
||||
private static final long serialVersionUID = 855135446595485715L;
|
||||
private static final Logger logger = Logger.getLogger(EventImpl.class.getName());
|
||||
|
||||
private final Set<Regatta> regattas;
|
||||
|
||||
private ConcurrentLinkedQueue<LeaderboardGroup> leaderboardGroups;
|
||||
|
||||
private transient ConcurrentHashMap<URL, Future<ImageSize>> imageSizeFetchers;
|
||||
private transient ExecutorService executor;
|
||||
|
||||
public EventImpl(String name, TimePoint startDate, TimePoint endDate, String venueName, boolean isPublic, UUID id) {
|
||||
this(name, startDate, endDate, new VenueImpl(venueName), isPublic, id);
|
||||
}
|
||||
@@ -54,8 +33,6 @@ public class EventImpl extends EventBaseImpl implements Event {
|
||||
super(name, startDate, endDate, venue, isPublic, id);
|
||||
this.regattas = new HashSet<Regatta>();
|
||||
this.leaderboardGroups = new ConcurrentLinkedQueue<>();
|
||||
this.imageSizeFetchers = new ConcurrentHashMap<>();
|
||||
this.executor = Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
@@ -63,8 +40,6 @@ public class EventImpl extends EventBaseImpl implements Event {
|
||||
if (leaderboardGroups == null) {
|
||||
leaderboardGroups = new ConcurrentLinkedQueue<>();
|
||||
}
|
||||
this.imageSizeFetchers = new ConcurrentHashMap<>();
|
||||
this.executor = Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,110 +81,4 @@ public class EventImpl extends EventBaseImpl implements Event {
|
||||
public boolean removeLeaderboardGroup(LeaderboardGroup leaderboardGroup) {
|
||||
return leaderboardGroups.remove(leaderboardGroup);
|
||||
}
|
||||
|
||||
private Future<ImageSize> getOrCreateImageSizeCalculator(final URL imageURL) {
|
||||
Future<ImageSize> imageSizeFetcher = imageSizeFetchers.get(imageURL);
|
||||
if (imageSizeFetcher == null) {
|
||||
imageSizeFetcher = executor.submit(new Callable<ImageSize>() {
|
||||
@Override
|
||||
public ImageSize call() throws IOException {
|
||||
ImageSize result = null;
|
||||
ImageInputStream in = null;
|
||||
try {
|
||||
URLConnection conn = imageURL.openConnection();
|
||||
in = ImageIO.createImageInputStream(conn.getInputStream());
|
||||
final Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
|
||||
if (readers.hasNext()) {
|
||||
ImageReader reader = readers.next();
|
||||
try {
|
||||
reader.setInput(in);
|
||||
result = new ImageSizeImpl(reader.getWidth(0), reader.getHeight(0));
|
||||
} finally {
|
||||
reader.dispose();
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
logger.log(Level.SEVERE, "Stale image link "+imageURL+" for event "+getName()+". Please double-check and replace or remove.", ioe);
|
||||
throw ioe;
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
imageSizeFetchers.put(imageURL, imageSizeFetcher);
|
||||
}
|
||||
return imageSizeFetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageSize getImageSize(URL imageURL) throws InterruptedException, ExecutionException {
|
||||
Future<ImageSize> imageSizeCalculator = getOrCreateImageSizeCalculator(imageURL);
|
||||
return imageSizeCalculator.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addImageURL(URL imageURL) {
|
||||
super.addImageURL(imageURL);
|
||||
refreshImageSizeFetcher(imageURL);
|
||||
}
|
||||
|
||||
private void refreshImageSizeFetcher(URL imageURL) {
|
||||
if (imageURL != null) {
|
||||
removeImageSizeFetcher(imageURL);
|
||||
getOrCreateImageSizeCalculator(imageURL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeImageURL(URL imageURL) {
|
||||
super.removeImageURL(imageURL);
|
||||
removeImageSizeFetcher(imageURL);
|
||||
}
|
||||
|
||||
private void removeImageSizeFetcher(URL imageURL) {
|
||||
if (imageURL != null) {
|
||||
imageSizeFetchers.remove(imageURL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageURLs(Iterable<URL> imageURLs) {
|
||||
super.setImageURLs(imageURLs);
|
||||
if (imageURLs != null) {
|
||||
for (URL imageURL : imageURLs) {
|
||||
refreshImageSizeFetcher(imageURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSponsorImageURL(URL sponsorImageURL) {
|
||||
super.addSponsorImageURL(sponsorImageURL);
|
||||
refreshImageSizeFetcher(sponsorImageURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSponsorImageURL(URL sponsorImageURL) {
|
||||
super.removeSponsorImageURL(sponsorImageURL);
|
||||
removeImageSizeFetcher(sponsorImageURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSponsorImageURLs(Iterable<URL> sponsorImageURLs) {
|
||||
super.setSponsorImageURLs(sponsorImageURLs);
|
||||
if (sponsorImageURLs != null) {
|
||||
for (URL imageURL : sponsorImageURLs) {
|
||||
refreshImageSizeFetcher(imageURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImageURL(URL logoImageURL) {
|
||||
super.setLogoImageURL(logoImageURL);
|
||||
refreshImageSizeFetcher(logoImageURL);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user