Skip to content

Commit

Permalink
Merge pull request #144 from turesheim/develop
Browse files Browse the repository at this point in the history
Configure for SonarCloud
  • Loading branch information
turesheim committed Oct 2, 2019
2 parents ea5c367 + 284e671 commit 29e328e
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 291 deletions.
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
14 changes: 12 additions & 2 deletions .travis.yml
@@ -1,11 +1,21 @@
language: java
sudo: false
script: mvn clean verify -Pskip-ui-tests
dist: trusty
sudo: required

# UI-tests will only run on macOS, so we skip these here
script:
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pskip-ui-tests -Dtycho.localArtifacts=ignore
- sonar-scanner
jdk:
- openjdk8
cache:
directories:
- $HOME/.m2
addons:
sonarcloud:
organization: "turesheim-github"
token:
secure: "ASUilEjJT5fYjMN6Cy5gVeY1fuKiIwEKLX9sxPltAowFABpzzimgLy+Ytbvh1GLsqnCXtVOYSkcClpNHezkuJwVMopj/IQiVl3cB9Qm3BySCgsQVPWHy2+DZ/sMMVMoVdtiQaycP3a8GY3tbi6Wofbb090vmPHNcn13AWEWXOBA="
deploy:
# Deploy to GitHub releases if the master branch has been tagged
provider: releases
Expand Down
28 changes: 14 additions & 14 deletions default.target
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
<target name="Eclipse Timekeeper Target Platform" sequenceNumber="1567631574">
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Eclipse Timekeeper Target Platform" sequenceNumber="1570022577">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.equinox.p2.sdk.feature.group" version="3.11.400.v20190516-1504"/>
<unit id="org.eclipse.sdk.feature.group" version="4.12.0.v20190605-1801"/>
<unit id="org.eclipse.pde.core" version="3.13.0.v20190513-1223"/>
<unit id="org.eclipse.emf.ecore" version="2.18.0.v20190528-0845"/>
<unit id="org.eclipse.equinox.p2.sdk.feature.group" version="3.11.500.v20190903-0934"/>
<unit id="org.eclipse.sdk.feature.group" version="4.13.0.v20190916-1323"/>
<unit id="org.eclipse.pde.core" version="3.13.100.v20190830-1158"/>
<unit id="org.eclipse.emf.ecore" version="2.19.0.v20190822-1451"/>
<unit id="org.eclipse.emf.ecore.xmi" version="2.16.0.v20190528-0725"/>
<unit id="org.eclipse.emf.ecore.change" version="2.14.0.v20190528-0725"/>
<unit id="org.eclipse.emf.common" version="2.16.0.v20190528-0845"/>
<unit id="org.eclipse.emf.common" version="2.16.0.v20190625-1131"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.commons.collections" version="3.2.2.v201511171945"/>
<repository location="http://download.eclipse.org/releases/2019-06/"/>
<repository location="http://download.eclipse.org/releases/2019-09/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.swtbot.forms.source.feature.group" version="2.8.0.201906121535"/>
Expand All @@ -30,7 +30,7 @@
<unit id="org.eclipse.mylyn.bugzilla.core" version="3.25.0.v20190128-2356"/>
<unit id="org.eclipse.mylyn.commons.ui" version="3.25.0.v20180706-1510"/>
<unit id="org.eclipse.mylyn.bugzilla_feature.feature.group" version="3.25.0.v20190128-2356"/>
<repository location="https://download.eclipse.org/mylyn/releases/3.25/"/>
<repository location="https://download.eclipse.org/mylyn/releases/latest/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="com.atlassian.connector.eclipse.feature.group" version="3.2.5.v20150427"/>
Expand All @@ -40,22 +40,22 @@
<unit id="javax.persistence" version="2.2.1.v201807122140"/>
<unit id="javax.activation" version="1.1.0.v201108011116"/>
<unit id="javax.xml.bind" version="2.2.12.v201410011542"/>
<unit id="org.eclipse.persistence.core" version="2.7.5.v20190826-74490fb827"/>
<unit id="org.eclipse.persistence.jpa" version="2.7.5.v20190826-74490fb827"/>
<unit id="org.eclipse.persistence.jpa.jpql" version="2.7.5.v20190826-74490fb827"/>
<unit id="org.eclipse.persistence.core" version="2.7.5.v20191001-428561e69a"/>
<unit id="org.eclipse.persistence.jpa" version="2.7.5.v20191001-428561e69a"/>
<unit id="org.eclipse.persistence.jpa.jpql" version="2.7.5.v20191001-428561e69a"/>
<unit id="org.eclipse.persistence.asm" version="6.2.0.v201808041654"/>
<repository location="https://download.eclipse.org/rt/eclipselink/nightly-updates/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.gemini.jpa" version="1.2.0.M1"/>
<repository location="https://download.eclipse.org/gemini/jpa/updates/1.2.0-M1"/>
<repository location="https://download.eclipse.org/gemini/jpa/updates/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.slf4j.api" version="1.7.10.v20170428-1633"/>
<unit id="ch.qos.logback.slf4j" version="1.1.2.v20160301-0943"/>
<unit id="ch.qos.logback.classic" version="1.1.2.v20171220-1825"/>
<unit id="ch.qos.logback.core" version="1.1.2.v20160208-0839"/>
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/I20190602181010/repository"/>
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190827152740/repository"/>
</location>
</locations>
</target>
14 changes: 7 additions & 7 deletions default.tpd
@@ -1,7 +1,7 @@
target "Eclipse Timekeeper Target Platform" with source requirements

// Base dependencies
location "http://download.eclipse.org/releases/2019-06/" {
location "http://download.eclipse.org/releases/2019-09/" {
org.eclipse.equinox.p2.sdk.feature.group
org.eclipse.sdk.feature.group
org.eclipse.pde.core
Expand All @@ -22,8 +22,8 @@ location "http://download.eclipse.org/technology/swtbot/releases/2.8.0/" {
org.hamcrest.core
}

// Mylyn bits, 2019-6-28 release for Eclipse 4.11 and 4.12
location "https://download.eclipse.org/mylyn/releases/3.25/" {
// Mylyn bits
location "https://download.eclipse.org/mylyn/releases/latest/" {
org.eclipse.mylyn.tasks.core
org.eclipse.mylyn.tasks.ui
org.apache.commons.lang
Expand All @@ -39,7 +39,7 @@ location "http://update.atlassian.com/atlassian-eclipse-plugin/rest/e3.7/" {
}

// EclipseLink for persistence
// 2.7.3 appears to be broken,
// 2.7.3 appears to be broken so the nightly builds are used
location "https://download.eclipse.org/rt/eclipselink/nightly-updates/" {
javax.persistence
javax.activation
Expand All @@ -50,11 +50,11 @@ location "https://download.eclipse.org/rt/eclipselink/nightly-updates/" {
org.eclipse.persistence.asm [6.2.0,7.0.0)
}

location "https://download.eclipse.org/gemini/jpa/updates/1.2.0-M1" {
org.eclipse.gemini.jpa
location "https://download.eclipse.org/gemini/jpa/updates/" {
org.eclipse.gemini.jpa [1.2.0,2.0.0)
}

location "http://download.eclipse.org/tools/orbit/downloads/drops/I20190602181010/repository" {
location "https://download.eclipse.org/tools/orbit/downloads/drops/R20190827152740/repository" {
org.slf4j.api
ch.qos.logback.slf4j
ch.qos.logback.classic
Expand Down
2 changes: 1 addition & 1 deletion net.resheim.eclipse.timekeeper-site/pom.xml
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>net.resheim.eclipse.timekeeper-site</artifactId>
<name>Eclipse Timekeeper p2 Repository</name>
<name>Timekeeper for Eclipse p2 Repository</name>
<packaging>eclipse-repository</packaging>
<build>
<plugins>
Expand Down
Expand Up @@ -8,7 +8,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
1 change: 1 addition & 0 deletions net.resheim.eclipse.timekeeper.db/META-INF/MANIFEST.MF
Expand Up @@ -66,3 +66,4 @@ Bundle-ClassPath: lib/h2-1.4.194.jar,
.
Bundle-ActivationPolicy: lazy
Bundle-Activator: net.resheim.eclipse.timekeeper.db.TimekeeperPlugin
Bundle-Vendor: Torkild U. Resheim
Expand Up @@ -33,42 +33,44 @@
* however that should typically not be the case. Multiple activities can be
* assign to the same {@link TrackedTask}, on the same day.
*
* TODO: Consolidate activities so they never span dates. It will make several operations much easier.
* TODO: Consolidate activities so they never span dates. It will make several
* operations much easier.
*
* @author Torkild U. Resheim
*/
@Entity(name = "ACTIVITY")
@UuidGenerator(name = "uuid")
public class Activity implements Comparable<Activity>{
public class Activity implements Comparable<Activity> {

@Id
@GeneratedValue(generator="uuid")
@GeneratedValue(generator = "uuid")
@Column(name = "ID")
private String id;

/** The time the activity was started */
@Column(name = "START_TIME")
@Convert(converter = LocalDateTimeAttributeConverter.class)
private LocalDateTime start = null;

/** The time the activity was stopped */
@Column(name = "END_TIME")
@Convert(converter = LocalDateTimeAttributeConverter.class)
private LocalDateTime end = null;

/** Whether or not activity properties have been manually adjusted or created */
@Column(name = "ADJUSTED")
private boolean manual = false;

/** The task the activity is associated with */
@ManyToOne
@ManyToOne
private TrackedTask trackedtask;

/** A short summary of the activity */
@Column
private String summary;

protected Activity() {}

protected Activity() {
}

public Activity(TrackedTask trackedtask, LocalDateTime start) {
this.trackedtask = trackedtask;
Expand All @@ -89,31 +91,28 @@ public Activity(TrackedTask trackedtask, LocalDateTime start) {
public Duration getDuration() {
return Duration.between(getStart(), getEnd());
}

/**
* Returns the duration of work on the given date if any.
*
* @param date
* the date to calculate for
* @param date the date to calculate for
* @return the amount of work occuring on the given date
*/
public Duration getDuration(LocalDate date) {
return getDuration(date, date.plusDays(1));
}

/**
* Returns the duration of the activity between the given dates.
*
* @param start
* the start date
* @param end
* the end date
* @param start the start date
* @param end the end date
* @return the duration of work between the two days
*/
public Duration getDuration(LocalDate start, LocalDate end) {
LocalDateTime min = LocalDateTime.of(start,LocalTime.MIN);
LocalDateTime max = LocalDateTime.of(end,LocalTime.MIN);
LocalDateTime min = LocalDateTime.of(start, LocalTime.MIN);
LocalDateTime max = LocalDateTime.of(end, LocalTime.MIN);

LocalDateTime s = getStart();
LocalDateTime e = getEnd();

Expand All @@ -122,7 +121,7 @@ public Duration getDuration(LocalDate start, LocalDate end) {
if (e == null) {
e = LocalDateTime.now();
}

if (s.isAfter(max) || e.isBefore(min)) {
return Duration.ZERO;
}
Expand All @@ -132,24 +131,23 @@ public Duration getDuration(LocalDate start, LocalDate end) {
d = d.minus(Duration.between(s, min));
}
if (e.isAfter(max)) {
d = d.minus(Duration.between(max,e));
d = d.minus(Duration.between(max, e));
}
return d;
}

/**
* Specifies the duration of the activity by modifying the end time. Also
* sets the <i>manual</i> flag indicating that this activity was manually
* created or edited.
* Specifies the duration of the activity by modifying the end time. Also sets
* the <i>manual</i> flag indicating that this activity was manually created or
* edited.
*
* @param duration
* the duration
* @param duration the duration
*/
public void setDuration(Duration duration) {
end = start.plus(duration);
manual = true;
}

public LocalDateTime getEnd() {
return end;
}
Expand All @@ -169,10 +167,10 @@ public void setStart(LocalDateTime start) {
public boolean isEdited() {
return manual;
}
public TrackedTask getTrackedTask() {
return trackedtask;
}

public TrackedTask getTrackedTask() {
return trackedtask;
}

public String getSummary() {
return summary;
Expand Down
Expand Up @@ -13,5 +13,5 @@
public interface DatabaseChangeListener {

public void databaseStateChanged();

}
Expand Up @@ -31,7 +31,7 @@
import net.resheim.eclipse.timekeeper.db.report.ReportTemplate;

/**
* Specifies default values for the core Timekeeper preferences.
* Specifies default values for the core Timekeeper preferences.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {

Expand All @@ -40,15 +40,18 @@ public void initializeDefaultPreferences() {
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, TimekeeperPlugin.BUNDLE_ID);
try {
store.setDefault(TimekeeperPlugin.PREF_DATABASE_LOCATION, TimekeeperPlugin.PREF_DATABASE_LOCATION_SHARED);
store.setDefault(TimekeeperPlugin.PREF_DATABASE_LOCATION_URL, TimekeeperPlugin.getDefault().getSharedLocation());
// read from the "templates" directory and create a list of templates – all files stored there
// will be registered.
store.setDefault(TimekeeperPlugin.PREF_DATABASE_LOCATION_URL,
TimekeeperPlugin.getDefault().getSharedLocation());
// read from the "templates" directory and create a list of templates – all
// files stored there
// will be registered.
Bundle bundle = TimekeeperPlugin.getDefault().getBundle();
Enumeration<URL> findEntries = bundle.findEntries("templates", "*", true);
List<ReportTemplate> templates = new ArrayList<>();
while (findEntries.hasMoreElements()) {
URL url = findEntries.nextElement();
// open stream directly instead of resolving the URI, which would barf on spaces in path
// open stream directly instead of resolving the URI, which would barf on spaces
// in path
InputStream is = url.openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("utf-8")));
StringBuilder sb = new StringBuilder();
Expand All @@ -67,10 +70,11 @@ public void initializeDefaultPreferences() {
} else if (url.getFile().endsWith(".rtf")) {
type = ReportTemplate.Type.RTF;
}
templates.add(new ReportTemplate(name,type, sb.toString()));
templates.add(new ReportTemplate(name, type, sb.toString()));
}
// serialize the list of templates to a string and store it in the preferences
try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out)){
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out)) {
oos.writeObject(templates);
String encoded = Base64.getEncoder().encodeToString(out.toByteArray());
store.setDefault(TimekeeperPlugin.PREF_REPORT_TEMPLATES, encoded);
Expand Down

0 comments on commit 29e328e

Please sign in to comment.