Skip to content

Commit 98ee7fd

Browse files
committed
Compatible with Communitiy Commons 7.2
1 parent 5b27ead commit 98ee7fd

File tree

72 files changed

+3193
-3156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3193
-3156
lines changed

DIST/RestServices_mx7_4.3.0.mpk

912 KB
Binary file not shown.

RestServices.mpr

8 KB
Binary file not shown.

javasource/communitycommons/ConversationLog.java

-471
This file was deleted.
+68-68
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
package communitycommons;
2-
3-
import java.util.Calendar;
4-
import java.util.Date;
5-
6-
import communitycommons.proxies.DatePartSelector;
7-
8-
public class DateTime
9-
{
10-
/**
11-
* @author mwe
12-
* Berekent aantal jaar sinds een bepaalde datum. Als einddatum == null, het huidige tijdstip wordt gebruikt
13-
* Code is gebaseerd op http://stackoverflow.com/questions/1116123/how-do-i-calculate-someones-age-in-java
14-
*/
15-
public static long yearsBetween(Date birthdate, Date comparedate) {
16-
if (birthdate == null)
17-
return -1L;
18-
19-
Calendar now = Calendar.getInstance();
20-
if (comparedate != null)
21-
now.setTime(comparedate);
22-
Calendar dob = Calendar.getInstance();
23-
dob.setTime(birthdate);
24-
if (dob.after(now))
25-
return -1L;
26-
27-
int year1 = now.get(Calendar.YEAR);
28-
int year2 = dob.get(Calendar.YEAR);
29-
long age = year1 - year2;
30-
int month1 = now.get(Calendar.MONTH);
31-
int month2 = dob.get(Calendar.MONTH);
32-
if (month2 > month1) {
33-
age--;
34-
} else if (month1 == month2) {
35-
int day1 = now.get(Calendar.DAY_OF_MONTH);
36-
int day2 = dob.get(Calendar.DAY_OF_MONTH);
37-
if (day2 > day1) {
38-
age--;
39-
}
40-
}
41-
return age;
42-
}
43-
44-
public static long dateTimeToLong(Date date)
45-
{
46-
return date.getTime();
47-
}
48-
49-
public static Date longToDateTime(Long value)
50-
{
51-
return new Date(value);
52-
}
53-
54-
public static long dateTimeToInteger(Date date, DatePartSelector selectorObj)
55-
{
56-
Calendar newDate = Calendar.getInstance();
57-
newDate.setTime(date);
58-
int value = -1;
59-
switch (selectorObj) {
60-
case year : value = newDate.get(Calendar.YEAR); break;
61-
case month : value = newDate.get(Calendar.MONTH)+1; break; // Return starts at 0
62-
case day : value = newDate.get(Calendar.DAY_OF_MONTH); break;
63-
default : break;
64-
}
65-
return value;
66-
}
67-
68-
}
1+
package communitycommons;
2+
3+
import java.util.Calendar;
4+
import java.util.Date;
5+
6+
import communitycommons.proxies.DatePartSelector;
7+
8+
public class DateTime
9+
{
10+
/**
11+
* @author mwe
12+
* Berekent aantal jaar sinds een bepaalde datum. Als einddatum == null, het huidige tijdstip wordt gebruikt
13+
* Code is gebaseerd op http://stackoverflow.com/questions/1116123/how-do-i-calculate-someones-age-in-java
14+
*/
15+
public static long yearsBetween(Date birthdate, Date comparedate) {
16+
if (birthdate == null)
17+
return -1L;
18+
19+
Calendar now = Calendar.getInstance();
20+
if (comparedate != null)
21+
now.setTime(comparedate);
22+
Calendar dob = Calendar.getInstance();
23+
dob.setTime(birthdate);
24+
if (dob.after(now))
25+
return -1L;
26+
27+
int year1 = now.get(Calendar.YEAR);
28+
int year2 = dob.get(Calendar.YEAR);
29+
long age = year1 - year2;
30+
int month1 = now.get(Calendar.MONTH);
31+
int month2 = dob.get(Calendar.MONTH);
32+
if (month2 > month1) {
33+
age--;
34+
} else if (month1 == month2) {
35+
int day1 = now.get(Calendar.DAY_OF_MONTH);
36+
int day2 = dob.get(Calendar.DAY_OF_MONTH);
37+
if (day2 > day1) {
38+
age--;
39+
}
40+
}
41+
return age;
42+
}
43+
44+
public static long dateTimeToLong(Date date)
45+
{
46+
return date.getTime();
47+
}
48+
49+
public static Date longToDateTime(Long value)
50+
{
51+
return new Date(value);
52+
}
53+
54+
public static long dateTimeToInteger(Date date, DatePartSelector selectorObj)
55+
{
56+
Calendar newDate = Calendar.getInstance();
57+
newDate.setTime(date);
58+
int value = -1;
59+
switch (selectorObj) {
60+
case year : value = newDate.get(Calendar.YEAR); break;
61+
case month : value = newDate.get(Calendar.MONTH)+1; break; // Return starts at 0
62+
case day : value = newDate.get(Calendar.DAY_OF_MONTH); break;
63+
default : break;
64+
}
65+
return value;
66+
}
67+
68+
}
+58-58
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
package communitycommons;
2-
3-
import org.apache.commons.lang3.builder.HashCodeBuilder;
4-
5-
6-
public class ImmutablePair<T, U>
7-
{
8-
public static <T, U> ImmutablePair<T, U> of(T left, U right) {
9-
return new ImmutablePair<T, U>(left, right);
10-
}
11-
12-
private final T left;
13-
private final U right;
14-
15-
private ImmutablePair(T left, U right) {
16-
if (left == null)
17-
throw new IllegalArgumentException("Left is NULL");
18-
if (right == null)
19-
throw new IllegalArgumentException("Right is NULL");
20-
21-
this.left = left;
22-
this.right = right;
23-
}
24-
25-
public T getLeft() {
26-
return left;
27-
}
28-
29-
public U getRight() {
30-
return right;
31-
}
32-
33-
@Override
34-
public String toString() {
35-
return "<" + left.toString()+ "," + right.toString() + ">";
36-
}
37-
38-
@Override
39-
public boolean equals(Object other) {
40-
if (!(other instanceof ImmutablePair<?,?>))
41-
return false;
42-
43-
if (this == other)
44-
return true;
45-
46-
ImmutablePair<?,?> o = (ImmutablePair<?, ?>) other;
47-
return left.equals(o.getLeft()) && right.equals(o.getRight());
48-
}
49-
50-
@Override
51-
public int hashCode() {
52-
return new HashCodeBuilder(19, 85)
53-
.append(left)
54-
.append(right)
55-
.toHashCode();
56-
}
57-
58-
}
1+
package communitycommons;
2+
3+
import org.apache.commons.lang3.builder.HashCodeBuilder;
4+
5+
6+
public class ImmutablePair<T, U>
7+
{
8+
public static <T, U> ImmutablePair<T, U> of(T left, U right) {
9+
return new ImmutablePair<T, U>(left, right);
10+
}
11+
12+
private final T left;
13+
private final U right;
14+
15+
private ImmutablePair(T left, U right) {
16+
if (left == null)
17+
throw new IllegalArgumentException("Left is NULL");
18+
if (right == null)
19+
throw new IllegalArgumentException("Right is NULL");
20+
21+
this.left = left;
22+
this.right = right;
23+
}
24+
25+
public T getLeft() {
26+
return left;
27+
}
28+
29+
public U getRight() {
30+
return right;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return "<" + left.toString()+ "," + right.toString() + ">";
36+
}
37+
38+
@Override
39+
public boolean equals(Object other) {
40+
if (!(other instanceof ImmutablePair<?,?>))
41+
return false;
42+
43+
if (this == other)
44+
return true;
45+
46+
ImmutablePair<?,?> o = (ImmutablePair<?, ?>) other;
47+
return left.equals(o.getLeft()) && right.equals(o.getRight());
48+
}
49+
50+
@Override
51+
public int hashCode() {
52+
return new HashCodeBuilder(19, 85)
53+
.append(left)
54+
.append(right)
55+
.toHashCode();
56+
}
57+
58+
}
+69-65
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,69 @@
1-
package communitycommons;
2-
3-
import java.util.Date;
4-
import java.util.HashMap;
5-
import java.util.Map;
6-
7-
import com.mendix.core.Core;
8-
import com.mendix.logging.ILogNode;
9-
import communitycommons.proxies.LogLevel;
10-
11-
public class Logging
12-
{
13-
private static Map<String, Long> timers = new HashMap<String, Long>();
14-
15-
public static void log(String lognode, LogLevel loglevel, String message)
16-
{
17-
log(lognode, loglevel, message, null);
18-
}
19-
20-
public static void log(String lognode, LogLevel loglevel, String message, Throwable e) {
21-
ILogNode logger = Core.getLogger(lognode);
22-
switch (loglevel) {
23-
case Critical:
24-
logger.critical(message,e);
25-
break;
26-
case Warning:
27-
logger.warn(message,e);
28-
break;
29-
case Debug:
30-
logger.debug(message);
31-
break;
32-
case Error:
33-
logger.error(message,e);
34-
break;
35-
case Info:
36-
logger.info(message);
37-
break;
38-
case Trace:
39-
logger.trace(message);
40-
break;
41-
}
42-
}
43-
44-
public static void simpleLog(String message)
45-
{
46-
Core.getLogger("Community_Commons").info(message);
47-
}
48-
49-
50-
public static Long measureEnd(String timerName, LogLevel loglevel,
51-
String message)
52-
{
53-
Long cur = new Date().getTime();
54-
if (!timers.containsKey(timerName))
55-
throw new IllegalArgumentException();
56-
String time = String.format("%d", cur - timers.get(timerName));
57-
log("Utility_log", loglevel, "Timer " + timerName + " finished in " + time + " ms. " + message);
58-
return timers.get(timerName);
59-
}
60-
61-
public static void measureStart(String timerName)
62-
{
63-
timers.put(timerName, new Date().getTime());
64-
}
65-
}
1+
package communitycommons;
2+
3+
import java.util.Date;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
7+
import com.mendix.core.Core;
8+
import com.mendix.logging.ILogNode;
9+
import communitycommons.proxies.LogLevel;
10+
11+
public class Logging
12+
{
13+
private static Map<String, Long> timers = new HashMap<String, Long>();
14+
15+
public static void log(String lognode, LogLevel loglevel, String message)
16+
{
17+
log(lognode, loglevel, message, null);
18+
}
19+
20+
public static void log(String lognode, LogLevel loglevel, String message, Throwable e) {
21+
ILogNode logger = Core.getLogger(lognode);
22+
switch (loglevel) {
23+
case Critical:
24+
logger.critical(message,e);
25+
break;
26+
case Warning:
27+
logger.warn(message,e);
28+
break;
29+
case Debug:
30+
logger.debug(message);
31+
break;
32+
case Error:
33+
logger.error(message,e);
34+
break;
35+
case Info:
36+
logger.info(message);
37+
break;
38+
case Trace:
39+
logger.trace(message);
40+
break;
41+
}
42+
}
43+
44+
public static void simpleLog(String message)
45+
{
46+
Core.getLogger("Community_Commons").info(message);
47+
}
48+
49+
50+
public static Long measureEnd(String timerName, LogLevel loglevel,
51+
String message)
52+
{
53+
Long cur = new Date().getTime();
54+
if (!timers.containsKey(timerName))
55+
throw new IllegalArgumentException();
56+
String time = String.format("%d", cur - timers.get(timerName));
57+
log("Utility_log", loglevel, "Timer " + timerName + " finished in " + time + " ms. " + message);
58+
return timers.get(timerName);
59+
}
60+
61+
public static void measureStart(String timerName)
62+
{
63+
timers.put(timerName, new Date().getTime());
64+
}
65+
66+
public static void createLogNode(String logNode) {
67+
Core.getLogger(logNode);
68+
}
69+
}

0 commit comments

Comments
 (0)