Skip to content

Commit

Permalink
Merge branch 'v0.17.x_bugfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jan 25, 2019
2 parents e414e5e + 86e6803 commit 0b9ea75
Show file tree
Hide file tree
Showing 26 changed files with 1,351 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,37 @@
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToCalendar;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToFormattedString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToInstant;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToLocalDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToLocalDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToLocalTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToSQLDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToSQLTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToTimestamp;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateAndTimeValueToZonedDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToCalendar;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToFormattedString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToInstant;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToLocalDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToLocalDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToSQLDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToSQLTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToTimestamp;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.DateValueToZonedDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToCalendar;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToFormattedString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToInstant;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToLocalDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToLocalTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToSQLDate;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToSQLTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToString;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToTimestamp;
import de.gebit.integrity.parameter.conversion.conversions.integrity.dates.TimeValueToZonedDateTime;
import de.gebit.integrity.parameter.conversion.conversions.integrity.javaconstants.JavaConstantToAnything;
import de.gebit.integrity.parameter.conversion.conversions.integrity.javaconstants.JavaConstantToMap;
import de.gebit.integrity.parameter.conversion.conversions.integrity.nestedobjects.NestedObjectToBean;
Expand Down Expand Up @@ -310,6 +323,21 @@ protected void initializeConversions() {
addConversion(TimeValueToSQLTime.class);
addConversion(TimeValueToTimestamp.class);

// Java8 date/time conversions, Integrity -> Java
addConversion(DateAndTimeValueToInstant.class);
addConversion(DateAndTimeValueToLocalDateTime.class);
addConversion(DateAndTimeValueToZonedDateTime.class);
addConversion(DateAndTimeValueToLocalDate.class);
addConversion(DateAndTimeValueToLocalTime.class);
addConversion(DateValueToInstant.class);
addConversion(DateValueToLocalDate.class);
addConversion(DateValueToLocalDateTime.class);
addConversion(DateValueToZonedDateTime.class);
addConversion(TimeValueToInstant.class);
addConversion(TimeValueToLocalDateTime.class);
addConversion(TimeValueToLocalTime.class);
addConversion(TimeValueToZonedDateTime.class);

// nested objects, Integrity -> Java
addConversion(NestedObjectToMap.class);
addConversion(NestedObjectToString.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.Instant;
import java.util.Date;

import de.gebit.integrity.dsl.DateAndTimeValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateAndTimeValueToInstant extends Conversion<DateAndTimeValue, Instant> {

@Override
public Instant convert(DateAndTimeValue aSource, Class<? extends Instant> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return DateUtil.convertDateAndTimeValue(aSource).toInstant();
} catch (ParseException exc) {
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

import de.gebit.integrity.dsl.DateAndTimeValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateAndTimeValueToLocalDate extends Conversion<DateAndTimeValue, LocalDate> {

@Override
public LocalDate convert(DateAndTimeValue aSource, Class<? extends LocalDate> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return LocalDateTime
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault()))
.toLocalDate();
} catch (ParseException exc) {
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

import de.gebit.integrity.dsl.DateAndTimeValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateAndTimeValueToLocalDateTime extends Conversion<DateAndTimeValue, LocalDateTime> {

@Override
public LocalDateTime convert(DateAndTimeValue aSource, Class<? extends LocalDateTime> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return LocalDateTime
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault()));
} catch (ParseException exc) {
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;

import de.gebit.integrity.dsl.DateAndTimeValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateAndTimeValueToLocalTime extends Conversion<DateAndTimeValue, LocalTime> {

@Override
public LocalTime convert(DateAndTimeValue aSource, Class<? extends LocalTime> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return LocalDateTime
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault()))
.toLocalTime();
} catch (ParseException exc) {
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.GregorianCalendar;

import de.gebit.integrity.dsl.DateAndTimeValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateAndTimeValueToZonedDateTime extends Conversion<DateAndTimeValue, ZonedDateTime> {

@Override
public ZonedDateTime convert(DateAndTimeValue aSource, Class<? extends ZonedDateTime> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return ((GregorianCalendar) DateUtil.convertDateAndTimeValue(aSource)).toZonedDateTime();
} catch (ParseException exc) {
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.Instant;
import java.util.Date;

import de.gebit.integrity.dsl.DateValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateValueToInstant extends Conversion<DateValue, Instant> {

@Override
public Instant convert(DateValue aSource, Class<? extends Instant> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return DateUtil.convertDateValue(aSource).getTime().toInstant();
} catch (ParseException exc) {
throw new ConversionFailedException(DateValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

import de.gebit.integrity.dsl.DateValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateValueToLocalDate extends Conversion<DateValue, LocalDate> {

@Override
public LocalDate convert(DateValue aSource, Class<? extends LocalDate> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return LocalDate
.from(DateUtil.convertDateValue(aSource).getTime().toInstant().atZone(ZoneId.systemDefault()));
} catch (ParseException exc) {
throw new ConversionFailedException(DateValue.class, Date.class, null, exc);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

import de.gebit.integrity.dsl.DateValue;
import de.gebit.integrity.parameter.conversion.Conversion;
import de.gebit.integrity.parameter.conversion.ConversionContext;
import de.gebit.integrity.parameter.conversion.ConversionFailedException;
import de.gebit.integrity.utils.DateUtil;

/**
* A default Integrity conversion.
*
* @author Rene Schneider - initial API and implementation
*
*/
public class DateValueToLocalDateTime extends Conversion<DateValue, LocalDateTime> {

@Override
public LocalDateTime convert(DateValue aSource, Class<? extends LocalDateTime> aTargetType,
ConversionContext aConversionContext) throws ConversionFailedException {
try {
return LocalDateTime
.from(DateUtil.convertDateValue(aSource).getTime().toInstant().atZone(ZoneId.systemDefault()));
} catch (ParseException exc) {
throw new ConversionFailedException(DateValue.class, Date.class, null, exc);
}
}

}
Loading

0 comments on commit 0b9ea75

Please sign in to comment.