|
Lines 13-22
Link Here
|
| 13 |
*/ |
13 |
*/ |
| 14 |
package org.eclipse.emf.query2.internal.moinql.preprocessor; |
14 |
package org.eclipse.emf.query2.internal.moinql.preprocessor; |
| 15 |
|
15 |
|
|
|
16 |
import java.math.BigInteger; |
| 17 |
import java.text.ParseException; |
| 18 |
import java.text.SimpleDateFormat; |
| 16 |
import java.util.ArrayList; |
19 |
import java.util.ArrayList; |
| 17 |
import java.util.Arrays; |
20 |
import java.util.Arrays; |
|
|
21 |
import java.util.Calendar; |
| 18 |
import java.util.Collection; |
22 |
import java.util.Collection; |
| 19 |
import java.util.Collections; |
23 |
import java.util.Collections; |
|
|
24 |
import java.util.Date; |
| 20 |
import java.util.HashMap; |
25 |
import java.util.HashMap; |
| 21 |
import java.util.HashSet; |
26 |
import java.util.HashSet; |
| 22 |
import java.util.Iterator; |
27 |
import java.util.Iterator; |
|
Lines 24-29
Link Here
|
| 24 |
import java.util.Map; |
29 |
import java.util.Map; |
| 25 |
import java.util.Set; |
30 |
import java.util.Set; |
| 26 |
|
31 |
|
|
|
32 |
import javax.xml.datatype.XMLGregorianCalendar; |
| 33 |
|
| 27 |
import org.eclipse.emf.common.util.URI; |
34 |
import org.eclipse.emf.common.util.URI; |
| 28 |
import org.eclipse.emf.ecore.EAttribute; |
35 |
import org.eclipse.emf.ecore.EAttribute; |
| 29 |
import org.eclipse.emf.ecore.EClass; |
36 |
import org.eclipse.emf.ecore.EClass; |
|
Lines 34-39
Link Here
|
| 34 |
import org.eclipse.emf.ecore.EStructuralFeature; |
41 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 35 |
import org.eclipse.emf.ecore.EcorePackage; |
42 |
import org.eclipse.emf.ecore.EcorePackage; |
| 36 |
import org.eclipse.emf.ecore.util.EcoreUtil; |
43 |
import org.eclipse.emf.ecore.util.EcoreUtil; |
|
|
44 |
import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar; |
| 37 |
import org.eclipse.emf.query2.EmfHelper; |
45 |
import org.eclipse.emf.query2.EmfHelper; |
| 38 |
import org.eclipse.emf.query2.FromEntry; |
46 |
import org.eclipse.emf.query2.FromEntry; |
| 39 |
import org.eclipse.emf.query2.FromFixedSet; |
47 |
import org.eclipse.emf.query2.FromFixedSet; |
|
Lines 1064-1079
Link Here
|
| 1064 |
} |
1072 |
} |
| 1065 |
} |
1073 |
} |
| 1066 |
} else if (mqlWhereClause instanceof WhereString) { |
1074 |
} else if (mqlWhereClause instanceof WhereString) { |
| 1067 |
if (!(attrRes.attrType.equals(SpiFqlPrimitiveType.STRING))) { |
1075 |
if (attrRes.attrType.equals(SpiFqlPrimitiveType.DATE)){ |
|
|
1076 |
try{ |
| 1077 |
String sDt = ((WhereString) mqlWhereClause).getStringValue(); |
| 1078 |
value = new SimpleDateFormat("MM/dd/yyyy").parse(sDt); |
| 1079 |
}catch(ParseException p){ |
| 1080 |
throw new BugException(BugMessages.INVALID_DATE_FORMAT, mqlWhereClause.getClass().getCanonicalName(), |
| 1081 |
p.getMessage()); //$NON-NLS-1$ |
| 1082 |
|
| 1083 |
} |
| 1084 |
}else if (!(attrRes.attrType.equals(SpiFqlPrimitiveType.STRING))) { |
| 1068 |
this.reportError(mqlWhereClause, ApiMessages.COMPARISON_INCOMPATIBLE_TYPE_CHECK, new Object[] { attrName, |
1085 |
this.reportError(mqlWhereClause, ApiMessages.COMPARISON_INCOMPATIBLE_TYPE_CHECK, new Object[] { attrName, |
| 1069 |
attrRes.attrType, SpiFqlPrimitiveType.STRING }); |
1086 |
attrRes.attrType, SpiFqlPrimitiveType.STRING }); |
|
|
1087 |
value=null; |
| 1088 |
}else{ |
| 1089 |
value = ((WhereString) mqlWhereClause).getStringValue(); |
| 1070 |
} |
1090 |
} |
| 1071 |
value = ((WhereString) mqlWhereClause).getStringValue(); |
|
|
| 1072 |
} else { |
1091 |
} else { |
| 1073 |
throw new BugException(BugMessages.UNEXPECTED_SUBTYPE, mqlWhereClause.getClass().getCanonicalName(), |
1092 |
throw new BugException(BugMessages.UNEXPECTED_SUBTYPE, mqlWhereClause.getClass().getCanonicalName(), |
| 1074 |
"WhereComparator"); //$NON-NLS-1$ |
1093 |
"WhereComparator"); //$NON-NLS-1$ |
| 1075 |
} |
1094 |
} |
| 1076 |
|
|
|
| 1077 |
// if we are dealing with strings, check if we have trailing |
1095 |
// if we are dealing with strings, check if we have trailing |
| 1078 |
// blanks |
1096 |
// blanks |
| 1079 |
// in the constant or pattern. Also, a string cannot exceed a |
1097 |
// in the constant or pattern. Also, a string cannot exceed a |
|
Lines 1695-1700
Link Here
|
| 1695 |
// the caller permits like-operations) |
1713 |
// the caller permits like-operations) |
| 1696 |
ok = (operation.equals(Operation.EQUAL) || operation.equals(Operation.NOTEQUAL) || (operation.equals(Operation.LIKE) && likeOperationAllowed)); |
1714 |
ok = (operation.equals(Operation.EQUAL) || operation.equals(Operation.NOTEQUAL) || (operation.equals(Operation.LIKE) && likeOperationAllowed)); |
| 1697 |
break; |
1715 |
break; |
|
|
1716 |
case DATE: |
| 1717 |
ok = operation.equals(Operation.EQUAL) || operation.equals(Operation.NOTEQUAL) || operation.equals(Operation.SMALLER) || operation.equals(Operation.SMALLEREQUAL) || operation.equals(Operation.GREATER) || operation.equals(Operation.GREATEREQUAL); |
| 1718 |
break; |
| 1698 |
default: |
1719 |
default: |
| 1699 |
// all other types do not allow liking under any circumstances |
1720 |
// all other types do not allow liking under any circumstances |
| 1700 |
ok = !operation.equals(Operation.LIKE); |
1721 |
ok = !operation.equals(Operation.LIKE); |
|
Lines 1992-2006
Link Here
|
| 1992 |
Class<?> instanceClass = attrMofType.getInstanceClass(); |
2013 |
Class<?> instanceClass = attrMofType.getInstanceClass(); |
| 1993 |
if (primName.equals("EBoolean") || instanceClass == boolean.class || instanceClass == Boolean.class) { //$NON-NLS-1$ |
2014 |
if (primName.equals("EBoolean") || instanceClass == boolean.class || instanceClass == Boolean.class) { //$NON-NLS-1$ |
| 1994 |
attrType = SpiFqlPrimitiveType.BOOLEAN; |
2015 |
attrType = SpiFqlPrimitiveType.BOOLEAN; |
| 1995 |
} else if (primName.equals("EInt") || instanceClass == int.class || instanceClass == Integer.class) { //$NON-NLS-1$ |
2016 |
} else if (primName.equals("EInt") || instanceClass == int.class || instanceClass == Integer.class ) { //$NON-NLS-1$ |
| 1996 |
attrType = SpiFqlPrimitiveType.INTEGER; |
2017 |
attrType = SpiFqlPrimitiveType.INTEGER; |
| 1997 |
} else if (primName.equals("ELong") || instanceClass == long.class || instanceClass == Integer.class) { //$NON-NLS-1$ |
2018 |
} else if (primName.equals("ELong") || instanceClass == long.class || instanceClass == Integer.class || instanceClass == BigInteger.class) { //$NON-NLS-1$ |
| 1998 |
attrType = SpiFqlPrimitiveType.LONG; |
2019 |
attrType = SpiFqlPrimitiveType.LONG; |
| 1999 |
} else if (primName.equals("EFloat") || instanceClass == float.class || instanceClass == Float.class) { //$NON-NLS-1$ |
2020 |
} else if (primName.equals("EFloat") || instanceClass == float.class || instanceClass == Float.class) { //$NON-NLS-1$ |
| 2000 |
attrType = SpiFqlPrimitiveType.FLOAT; |
2021 |
attrType = SpiFqlPrimitiveType.FLOAT; |
| 2001 |
} else if (primName.equals("EDouble") || instanceClass == double.class || instanceClass == Double.class) { //$NON-NLS-1$ |
2022 |
} else if (primName.equals("EDouble") || instanceClass == double.class || instanceClass == Double.class) { //$NON-NLS-1$ |
| 2002 |
attrType = SpiFqlPrimitiveType.DOUBLE; |
2023 |
attrType = SpiFqlPrimitiveType.DOUBLE; |
| 2003 |
} else if (primName.equals("EString") || instanceClass == String.class) { //$NON-NLS-1$ |
2024 |
} else if (primName.equals("Date") || instanceClass == Date.class||instanceClass==XMLCalendar.class || instanceClass==XMLGregorianCalendar.class) { //$NON-NLS-1$ |
|
|
2025 |
attrType = SpiFqlPrimitiveType.DATE; |
| 2026 |
}else if (primName.equals("EString") || instanceClass == String.class) { //$NON-NLS-1$ |
| 2004 |
attrType = SpiFqlPrimitiveType.STRING; |
2027 |
attrType = SpiFqlPrimitiveType.STRING; |
| 2005 |
} else { |
2028 |
} else { |
| 2006 |
throw new BugException(BugMessages.UNKNOWN_PRIMITIVE_TYPE, primName); |
2029 |
throw new BugException(BugMessages.UNKNOWN_PRIMITIVE_TYPE, primName); |