Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "WeekOfQuarter" and "DayOfQuarter" to GroupingUnitType of the chart model. #478

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chart/org.eclipse.birt.chart.engine/src/model/model.xsd2ecore
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@
outputs="org.eclipse.birt.chart.model.attribute.ecore#//GroupingUnitType/DayOfMonth"/>
<nested inputs="../../xsd/attribute.xsd#//GroupingUnitType;XSDSimpleTypeDefinition=29/XSDEnumerationFacet=14"
outputs="org.eclipse.birt.chart.model.attribute.ecore#//GroupingUnitType/DayOfYear"/>
<nested inputs="../../xsd/attribute.xsd#//GroupingUnitType;XSDSimpleTypeDefinition=29/XSDEnumerationFacet=15"
outputs="org.eclipse.birt.chart.model.attribute.ecore#//GroupingUnitType/WeekOfQuarter"/>
<nested inputs="../../xsd/attribute.xsd#//GroupingUnitType;XSDSimpleTypeDefinition=29/XSDEnumerationFacet=16"
outputs="org.eclipse.birt.chart.model.attribute.ecore#//GroupingUnitType/DayOfQuarter"/>
</nested>
<nested inputs="../../xsd/data.xsd#//DataElement;XSDComplexTypeDefinition=9" outputs="org.eclipse.birt.chart.model.data.ecore#//DataElement"/>
<nested inputs="../../xsd/attribute.xsd#//DataType;XSDSimpleTypeDefinition=28" outputs="org.eclipse.birt.chart.model.attribute.ecore#//DataType">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@
<eLiterals name="DayOfWeek" value="12"/>
<eLiterals name="DayOfMonth" value="13"/>
<eLiterals name="DayOfYear" value="14"/>
<eLiterals name="WeekOfQuarter" value="15"/>
<eLiterals name="DayOfQuarter" value="16"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="GroupingUnitTypeObject" instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public static int groupingUnit2CDateUnit( GroupingUnitType groupingUnitType )
case GroupingUnitType.DAYS :
case GroupingUnitType.DAY_OF_MONTH :
return Calendar.DAY_OF_MONTH;
case GroupingUnitType.DAY_OF_QUARTER :
return CDateTime.DAY_OF_QUARTER;
case GroupingUnitType.DAY_OF_WEEK :
return Calendar.DAY_OF_WEEK;
case GroupingUnitType.DAY_OF_YEAR :
Expand All @@ -76,7 +78,9 @@ public static int groupingUnit2CDateUnit( GroupingUnitType groupingUnitType )
case GroupingUnitType.QUARTERS :
return CDateTime.QUARTER;
case GroupingUnitType.YEARS :
return Calendar.YEAR;
return Calendar.YEAR;
case GroupingUnitType.WEEK_OF_QUARTER :
return CDateTime.WEEK_OF_QUARTER;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,47 +147,70 @@ public enum GroupingUnitType implements Enumerator {
* @generated
* @ordered
*/
STRING_PREFIX_LITERAL(9, "StringPrefix", "StringPrefix"), /**
* The '<em><b>Week Of Month</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #WEEK_OF_MONTH
* @generated
* @ordered
*/
WEEK_OF_MONTH_LITERAL(10, "WeekOfMonth", "WeekOfMonth"), /**
* The '<em><b>Week Of Year</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #WEEK_OF_YEAR
* @generated
* @ordered
*/
WEEK_OF_YEAR_LITERAL(11, "WeekOfYear", "WeekOfYear"), /**
* The '<em><b>Day Of Week</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_WEEK
* @generated
* @ordered
*/
DAY_OF_WEEK_LITERAL(12, "DayOfWeek", "DayOfWeek"), /**
* The '<em><b>Day Of Month</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_MONTH
* @generated
* @ordered
*/
DAY_OF_MONTH_LITERAL(13, "DayOfMonth", "DayOfMonth"), /**
* The '<em><b>Day Of Year</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_YEAR
* @generated
* @ordered
*/
DAY_OF_YEAR_LITERAL(14, "DayOfYear", "DayOfYear");
STRING_PREFIX_LITERAL(9, "StringPrefix", "StringPrefix"),
/**
* The '<em><b>Week Of Month</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #WEEK_OF_MONTH
* @generated
* @ordered
*/
WEEK_OF_MONTH_LITERAL(10, "WeekOfMonth", "WeekOfMonth"),
/**
* The '<em><b>Week Of Year</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #WEEK_OF_YEAR
* @generated
* @ordered
*/
WEEK_OF_YEAR_LITERAL(11, "WeekOfYear", "WeekOfYear"),
/**
* The '<em><b>Day Of Week</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_WEEK
* @generated
* @ordered
*/
DAY_OF_WEEK_LITERAL(12, "DayOfWeek", "DayOfWeek"),
/**
* The '<em><b>Day Of Month</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_MONTH
* @generated
* @ordered
*/
DAY_OF_MONTH_LITERAL(13, "DayOfMonth", "DayOfMonth"),
/**
* The '<em><b>Day Of Year</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_YEAR
* @generated
* @ordered
*/
DAY_OF_YEAR_LITERAL(14, "DayOfYear", "DayOfYear"),
/**
* The '<em><b>Week Of Quarter</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #WEEK_OF_QUARTER
* @generated
* @ordered
*/
WEEK_OF_QUARTER_LITERAL(15, "WeekOfQuarter", "WeekOfQuarter"),
/**
* The '<em><b>Day Of Quarter</b></em>' literal object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #DAY_OF_QUARTER
* @generated
* @ordered
*/
DAY_OF_QUARTER_LITERAL(16, "DayOfQuarter", "DayOfQuarter");

/**
* The '<em><b>Seconds</b></em>' literal value.
Expand Down Expand Up @@ -386,6 +409,36 @@ public enum GroupingUnitType implements Enumerator {
*/
public static final int DAY_OF_YEAR = 14;

/**
* The '<em><b>Week Of Quarter</b></em>' literal value.
* <!-- begin-user-doc -->
* <p>
* If the meaning of '<em><b>Week Of Quarter</b></em>' literal object isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @see #WEEK_OF_QUARTER_LITERAL
* @model name="WeekOfQuarter"
* @generated
* @ordered
*/
public static final int WEEK_OF_QUARTER = 15;

/**
* The '<em><b>Day Of Quarter</b></em>' literal value.
* <!-- begin-user-doc -->
* <p>
* If the meaning of '<em><b>Day Of Quarter</b></em>' literal object isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @see #DAY_OF_QUARTER_LITERAL
* @model name="DayOfQuarter"
* @generated
* @ordered
*/
public static final int DAY_OF_QUARTER = 16;

/**
* An array of all the '<em><b>Grouping Unit Type</b></em>' enumerators.
* <!-- begin-user-doc --> <!-- end-user-doc -->
Expand All @@ -407,6 +460,8 @@ public enum GroupingUnitType implements Enumerator {
DAY_OF_WEEK_LITERAL,
DAY_OF_MONTH_LITERAL,
DAY_OF_YEAR_LITERAL,
WEEK_OF_QUARTER_LITERAL,
DAY_OF_QUARTER_LITERAL,
};

/**
Expand Down Expand Up @@ -492,6 +547,10 @@ public static GroupingUnitType get( int value )
return DAY_OF_MONTH_LITERAL;
case DAY_OF_YEAR :
return DAY_OF_YEAR_LITERAL;
case WEEK_OF_QUARTER :
return WEEK_OF_QUARTER_LITERAL;
case DAY_OF_QUARTER :
return DAY_OF_QUARTER_LITERAL;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4392,6 +4392,10 @@ public void initializePackageContents( )
GroupingUnitType.DAY_OF_MONTH_LITERAL );
addEEnumLiteral( groupingUnitTypeEEnum,
GroupingUnitType.DAY_OF_YEAR_LITERAL );
addEEnumLiteral( groupingUnitTypeEEnum,
GroupingUnitType.WEEK_OF_QUARTER_LITERAL );
addEEnumLiteral( groupingUnitTypeEEnum,
GroupingUnitType.DAY_OF_QUARTER_LITERAL );

initEEnum( horizontalAlignmentEEnum,
HorizontalAlignment.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class CDateTime extends GregorianCalendar
};

public static final int QUARTER = 999;
public static final int WEEK_OF_QUARTER = 1001;
public static final int DAY_OF_QUARTER = 1002;

private static int[] iaCalendarUnits = {
Calendar.SECOND,
Expand Down Expand Up @@ -912,9 +914,18 @@ else if ( iUnit == WEEK_OF_YEAR || iUnit == WEEK_OF_MONTH )
int weekDay = get( DAY_OF_WEEK );
add( DATE, 1 - weekDay );
}
else if ( iUnit == WEEK_OF_QUARTER )
{
set( Calendar.MILLISECOND, 0 );
set( Calendar.SECOND, 0 );
set( Calendar.MINUTE, 0 );
set( Calendar.HOUR, 0 );
set( Calendar.AM_PM, AM );
}
else if ( iUnit == DATE
|| iUnit == DAY_OF_MONTH
|| iUnit == DAY_OF_WEEK
|| iUnit == DAY_OF_QUARTER
|| iUnit == DAY_OF_YEAR )
{
set( Calendar.MILLISECOND, 0 );
Expand Down Expand Up @@ -979,11 +990,12 @@ else if ( iUnit == MONTH || iUnit == QUARTER )
else if ( iUnit == DATE
|| iUnit == DAY_OF_MONTH
|| iUnit == DAY_OF_WEEK
|| iUnit == DAY_OF_QUARTER
|| iUnit == DAY_OF_YEAR )
{
set( Calendar.YEAR, 2000 );
}
else if ( iUnit == WEEK_OF_YEAR || iUnit == WEEK_OF_MONTH )
else if ( iUnit == WEEK_OF_YEAR || iUnit == WEEK_OF_MONTH || iUnit == WEEK_OF_QUARTER )
{
set( Calendar.YEAR, 2000 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ public class ChartUtil
mapPattern.put( CDateTime.QUARTER, "QQQ" ); //$NON-NLS-1$
mapPattern.put( Calendar.MONTH, "MMM" ); //$NON-NLS-1$
mapPattern.put( Calendar.WEEK_OF_MONTH, "W" ); //$NON-NLS-1$
mapPattern.put( CDateTime.WEEK_OF_QUARTER, TEXT_WEEK + "C" ); //$NON-NLS-1$
mapPattern.put( Calendar.WEEK_OF_YEAR, "w" ); //$NON-NLS-1$
mapPattern.put( Calendar.DAY_OF_WEEK, "E" ); //$NON-NLS-1$
mapPattern.put( Calendar.DAY_OF_MONTH, "d" ); //$NON-NLS-1$
mapPattern.put( CDateTime.DAY_OF_QUARTER, TEXT_DAY + "c" ); //$NON-NLS-1$
mapPattern.put( Calendar.DAY_OF_YEAR, "D" ); //$NON-NLS-1$
mapPattern.put( Calendar.HOUR_OF_DAY, "HH" ); //$NON-NLS-1$
mapPattern.put( Calendar.MINUTE, "mm" ); //$NON-NLS-1$
Expand All @@ -144,10 +146,12 @@ public class ChartUtil
mapPatternHierarchy.put( Calendar.WEEK_OF_MONTH, TEXT_WEEK
+ "W MMM, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.WEEK_OF_YEAR, TEXT_WEEK + "w, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( CDateTime.WEEK_OF_QUARTER, TEXT_WEEK + "C QQQ, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.DAY_OF_WEEK, "E " //$NON-NLS-1$
+ TEXT_WEEK
+ "W MMM, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.DAY_OF_MONTH, "MMM dd, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( CDateTime.DAY_OF_QUARTER, TEXT_DAY + "c QQQ, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.DAY_OF_YEAR, TEXT_DAY + "D, yyyy" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.HOUR_OF_DAY, "HH:mm" ); //$NON-NLS-1$
mapPatternHierarchy.put( Calendar.MINUTE, "HH:mm:ss" ); //$NON-NLS-1$
Expand Down
2 changes: 2 additions & 0 deletions chart/org.eclipse.birt.chart.engine/xsd/attribute.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ enabled, by default it's true.</xsd:documentation>
<xsd:enumeration value="DayOfWeek"></xsd:enumeration>
<xsd:enumeration value="DayOfMonth"></xsd:enumeration>
<xsd:enumeration value="DayOfYear"></xsd:enumeration>
<xsd:enumeration value="WeekOfQuarter"></xsd:enumeration>
<xsd:enumeration value="DayOfQuarter"></xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="UnitsOfMeasurement">
Expand Down
2 changes: 2 additions & 0 deletions data/org.eclipse.birt.core.script.function/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ FunctionDesc.hour=Hour of date/time value.
FunctionDesc.minute=Minute of date/time value.
FunctionDesc.second=Second of date/time value.
FunctionDesc.weekOfMonth=Week number of the month of date/time value d ( (1 to 6).
FunctionDesc.weekOfQuarter=Week number of the quarter of date/time value d ( (1 to 15).
FunctionDesc.weekOfYear=Week number of the year of date/time value d ( (1 to 52).
FunctionDesc.day=Day number of the month(1 to 31).
FunctionDesc.weekDay=Day the week. Option is an integer value\n1: return a number 1 (Sunday) to 7 (Saturday);\n2: return a number 1 (Monday) to 7 (Sunday);\n3: return a number 0 (Monday) to 6 (Sunday);\n4: return the weekday name as per user locale(e.g., Sunday to Saturday for English);\n5: return the abbreviated weekday name as per user locale(e.g.,Sun to Sat for English)
FunctionDesc.dayOfWeek=Day number of the week (1 to 7).
FunctionDesc.dayOfYear=Day number of the year (1 to 366).
FunctionDesc.dayOfQuarter=Day number of the quarter ( 1 to 92 ).
FunctionDesc.dayOfMonth=Day number of the month (1 to 31).
FunctionDesc.today=Returns a timestamp value which is midnight of the current date.
FunctionDesc.now=Returns the current timestamp.
Expand Down
17 changes: 17 additions & 0 deletions data/org.eclipse.birt.core.script.function/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@
<DataType value="%dataType.DateTime"></DataType>
</Argument>
</Function>
<Function
desc="%FunctionDesc.weekOfQuarter"
name="weekOfQuarter"
isVisible="false">
<DataType value="%dataType.Integer"></DataType>
<Argument name="date">
<DataType value="%dataType.DateTime"></DataType>
</Argument>
</Function>
<Function
desc="%FunctionDesc.weekOfYear"
name="weekOfYear">
Expand Down Expand Up @@ -440,6 +449,14 @@
<Argument name="date">
<DataType value="%dataType.DateTime"></DataType></Argument>
</Function>
<Function
desc="%FunctionDesc.dayOfQuarter"
name="dayOfQuarter"
isVisible="false">
<DataType value="%dataType.Integer"></DataType>
<Argument name="date">
<DataType value="%dataType.DateTime"></DataType></Argument>
</Function>
<Function
desc="%FunctionDesc.dayOfMonth"
name="dayOfMonth">
Expand Down
Loading