diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..f43c2eb7359 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,116 @@ +version: 2 +defaults: &defaults + docker: + - image: appiriodevops/openjdk7:buildv1 + +install_dependency: &install_dependency + name: Installation of build dependencies. + command: | + sed -i '/jessie-updates/d' /etc/apt/sources.list + apt update + apt install -y openssl ant git zip jq + mkdir ~/awscli + cd ~/awscli + curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" + unzip awscli-bundle.zip + ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws + cd /usr/share/ant/lib + wget https://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/1.7.8/groovy-all-1.7.8.jar + wget https://repo1.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar + cd ~ + wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip + unzip jboss-4.2.3.GA-jdk6.zip + cd project +install_deploysuite: &install_deploysuite + name: Installation of install_deploysuite. + command: | + git clone --branch v1.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + cp ./../buildscript/master_deploy.sh . + cp ./../buildscript/buildenv.sh . + cp ./../buildscript/awsconfiguration.sh . +install_dependentrepo: &install_dependentrepo + name: Installation of install_deploysuite. + command: | + git clone --branch $GLUE_BRANCH https://github.com/topcoder-platform/tc-website-glue ../glue + git clone --branch $TCSHARED_BRANCH https://github.com/topcoder-platform/tc-website-shared ../shared + git clone --branch $TCEA_BRANCH https://github.com/topcoder-platform/tc-website-external-artifacts ../external-artifacts + git clone --branch $TCCACHE_BRANCH https://github.com/appirio-tech/tc-cache ../tc-cache +build_steps: &build_steps + # Initialization. + # - run: *install_dependency + - checkout + - run: *install_deploysuite + - run: *install_dependentrepo + - run: + name: "AWS Configuration" + command: | + ./awsconfiguration.sh $BUILD_ENV + source awsenvconf + - run: + name: Building application + command: | + source awsenvconf + ant -f move.xml package-topcoder + zip -r lib.zip lib + zip -r resources.zip resources + cd ../tc-cache && ant && cp build/dist/lib/tcs/tc_cache/1.0.0/tc_cache.jar ../project/ && cd ../project + # - store_artifacts: + # path: ./topcoder.jar + # destination: topcoder.jar + # - store_artifacts: + # path: ./tc_cache.jar + # destination: tc_cache.jar + - run: + name: Build Pacakge + command: ./build-package.sh $BUILD_ENV + - run: + name: "Deployment tc-website app" + command: | + source awsenvconf + echo $VER + # cp -f buildvar-app.conf buildvar.conf + ./deploy.sh $BUILD_ENV $VER + + +jobs: + # Build & Deploy against development backend + "build-dev": + <<: *defaults + environment: + BUILD_ENV: "DEV" + GLUE_BRANCH: "dev" + TCSHARED_BRANCH: "dev" + TCEA_BRANCH: "dev" + TCCACHE_BRANCH: "master" + steps: *build_steps + + "build-prod": + <<: *defaults + environment: + BUILD_ENV: "PROD" + GLUE_BRANCH: "master" + TCSHARED_BRANCH: "master" + TCEA_BRANCH: "master" + TCCACHE_BRANCH: "master" + steps: *build_steps + +workflows: + version: 2 + build: + jobs: + - Hold [TC-Website-Build-Deploy]: + type: approval + - build-dev: + context : org-global + requires: + - Hold [TC-Website-Build-Deploy] + filters: + branches: + only: [dev, reskin-payment] + - build-prod: + context : org-global + requires: + - Hold [TC-Website-Build-Deploy] + filters: + branches: + only: master diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 00000000000..c9dd9a24338 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,42 @@ +version: 0.0 +os: linux +files: + - source: ./topcoder.jar + destination: /home/web/web_backup/ + # - source: ./tc_cache.jar + # destination: /home/web/web_backup/ + # - source: ./lib.zip + # destination: /home/web/web_backup/ + # - source: ./resources.zip + # destination: /home/web/web_backup/ +permissions: + - object: /home/web/web_backup + pattern: "topcoder.jar" + owner: web + group: apps + # - object: /home/web/web_backup + # pattern: "tc_cache.jar" + # owner: web + # group: apps + # - object: /home/web/web_backup + # pattern: "lib.zip" + # owner: web + # group: apps + # - object: /home/web/web_backup + # pattern: "resources.zip" + # owner: web + # group: apps +hooks: + BeforeInstall: + - location: remote-cmd-backup-app.sh + runas: web + AfterInstall: + - location: remote-cmd-expand-app.sh + runas: web + - location: remote-cmd-stop-server.sh + runas: web + - location: remote-cmd-deploy-app.sh + runas: web + ApplicationStart: + - location: remote-cmd-start-server.sh + runas: web diff --git a/build-package.sh b/build-package.sh new file mode 100755 index 00000000000..784d2c3ea20 --- /dev/null +++ b/build-package.sh @@ -0,0 +1,29 @@ +#!/bin/bash +#Preparing paackage +ENV=$1 +if [ -z $ENV ]; +then + echo "The script need to be executed with version ex:build-package.sh ENV" + exit 1 +fi + +VER=`date "+%Y%m%d%H%M"` +SCRIPTDIR="./deployscripts" + +BUILD_VARIABLE_FILE_NAME="./buildvar.conf" +source $BUILD_VARIABLE_FILE_NAME +AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${VER}.zip" +PACAKAGE_LOCATION="dist-${PACKAGETYPE}" +rm -rf $PACAKAGE_LOCATION +mkdir $PACAKAGE_LOCATION +cp -rvf $SCRIPTDIR/* $PACAKAGE_LOCATION/ +cp lib.zip lib $PACAKAGE_LOCATION/ +cp resources.zip $PACAKAGE_LOCATION/ +cp topcoder.jar $PACAKAGE_LOCATION/ +cp tc_cache.jar $PACAKAGE_LOCATION/ +cp appspec.yml $PACAKAGE_LOCATION/appspec.yml +zip -j $AWS_CD_PACKAGE_NAME $PACAKAGE_LOCATION/* + + +VER1=$VER +echo export VER="$VER1" >> "$BASH_ENV" diff --git a/buildvar.conf b/buildvar.conf new file mode 100644 index 00000000000..aaaa0ab0bd3 --- /dev/null +++ b/buildvar.conf @@ -0,0 +1,15 @@ +APPNAME="tc-website" +PACKAGETYPE="app" +DEPLOY=1 +DEV_AWS_REGION="us-east-1" +DEV_AWS_CD_APPNAME="tc-website-app" +DEV_AWS_CD_DG_NAME="tc-website-app" +DEV_AWS_CD_DG_CONFIGURATION="CodeDeployDefault.AllAtOnce" +DEV_AWS_S3_BUCKET="tc-website-app-dev" +DEV_AWS_S3_KEY_LOCATION="" +PROD_AWS_REGION="us-east-1" +PROD_AWS_CD_APPNAME="tc-website-app" +PROD_AWS_CD_DG_NAME="tc-website-app" +PROD_AWS_CD_DG_CONFIGURATION="CodeDeployDefault.AllAtOnce" +PROD_AWS_S3_BUCKET="tc-website-app-prod" +PROD_AWS_S3_KEY_LOCATION="" diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 4baf3f224fc..00000000000 --- a/circle.yml +++ /dev/null @@ -1,14 +0,0 @@ -machine: - services: - - docker - -checkout: - pre: - - git clone https://github.com/topcoder-platform/tc-website-glue glue - - git clone https://github.com/topcoder-platform/tc-website-shared shared - - git clone https://github.com/topcoder-platform/tc-website-external-artifacts external-artifacts - - -test: - override: - - cp -Rf .deploy/circleci/* . && docker run -v ${HOME}:/root/tc-platform appiriodevops/tc-website:build diff --git a/conf/loadtcs.xml b/conf/loadtcs.xml index 329598ce8fe..52f73bf14cd 100755 --- a/conf/loadtcs.xml +++ b/conf/loadtcs.xml @@ -6,6 +6,8 @@ com.topcoder.utilities.dwload.TCLoadTCS + + - + \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 00000000000..be2f0b36ba3 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,125 @@ +#!/bin/bash + +ENV=$1 +APPVER=$2 + +if [ -z $APPVER ] || [ -z $ENV ]; +then + echo "The script need to be executed with version ex:deploy.sh ENV 123" + exit 1 +fi + +JQ="jq --raw-output --exit-status" +COUNTER_LIMIT=20 + +BUILD_VARIABLE_FILE_NAME="./buildvar.conf" +source $BUILD_VARIABLE_FILE_NAME + +AWS_CD_APPNAME=$(eval "echo \$${ENV}_AWS_CD_APPNAME") +AWS_CD_DG_NAME=$(eval "echo \$${ENV}_AWS_CD_DG_NAME") +AWS_CD_DG_CONFIGURATION=$(eval "echo \$${ENV}_AWS_CD_DG_CONFIGURATION") +AWS_S3_BUCKET=$(eval "echo \$${ENV}_AWS_S3_BUCKET") +AWS_S3_KEY_LOCATION=$(eval "echo \$${ENV}_AWS_S3_KEY_LOCATION") + +AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${APPVER}.zip" +if [ "$AWS_S3_KEY_LOCATION" = "" ] ; +then + AWS_S3_KEY="${AWS_CD_PACKAGE_NAME}" +else + AWS_S3_KEY="$AWS_S3_KEY_LOCATION/${AWS_CD_PACKAGE_NAME}" +fi +DEPLOYID="" +#log Function - Used to provide information of execution information with date and time +log() +{ + echo "`date +'%D %T'` : $1" +} + +#track_error function validates whether the application execute without any error +track_error() +{ + if [ $1 != "0" ]; then + log "$2 exited with error code $1" + log "completed execution IN ERROR at `date`" + exit $1 + fi + +} + +#uploading to S3 bucket +upload_cd_pakcage() +{ + S3_URL="" + if [ "$AWS_S3_KEY_LOCATION" = "" ] ; + then + S3_URL="s3://${AWS_S3_BUCKET}/" + else + S3_URL="s3://${AWS_S3_BUCKET}/${AWS_S3_KEY_LOCATION}/" + fi + aws s3 cp ${AWS_CD_PACKAGE_NAME} $S3_URL + track_error $? "Package S3 deployment" + log "CD Package uploaded successfully to S3 bucket $S3_URL" +} +#register the revision in Code deploy +update_cd_app_revision() +{ + aws deploy register-application-revision --application-name "${AWS_CD_APPNAME}" --s3-location "bucket=${AWS_S3_BUCKET},bundleType=zip,key=${AWS_S3_KEY}" + track_error $? "CD applicaton register" + log "CD application register completed successfully" +} +#Invoke the code deploy +cd_deploy() +{ + RESULT=`aws deploy create-deployment --application-name "${AWS_CD_APPNAME}" --deployment-config-name "${AWS_CD_DG_CONFIGURATION}" --deployment-group-name "${AWS_CD_DG_NAME}" --s3-location "bucket=${AWS_S3_BUCKET},bundleType=zip,key=${AWS_S3_KEY}"` + track_error $? "CD applicaton deployment intiation" + DEPLOYID=`echo $RESULT | $JQ .deploymentId` + log "CD application deployment initiation completed successfully. Please find the $DEPLOYID" +} +#Checing the status +cd_deploy_status() +{ + echo "check tatusget info aws deploy get-deployment --deployment-id $DEPLOYID" + counter=0 + BUFFER=0 + DEPLOYMENT_STATUS=`aws deploy get-deployment --deployment-id "$DEPLOYID" | $JQ .deploymentInfo.status` + if [ "$DEPLOYMENT_STATUS" = "Succeeded" ] || [ "$DEPLOYMENT_STATUS" = "Failed" ]; + then + BUFFER=1 + fi + while [ "$BUFFER" = "0" ] + do + echo "Current Deployment status : $DEPLOYMENT_STATUS" + echo "Waiting for 15 sec to check the Deployment status...." + sleep 15 + DEPLOYMENT_STATUS=`aws deploy get-deployment --deployment-id "$DEPLOYID" | $JQ .deploymentInfo.status` + if [ "$DEPLOYMENT_STATUS" = "Succeeded" ] || [ "$DEPLOYMENT_STATUS" = "Failed" ]; + then + BUFFER=1 + fi + counter=`expr $counter + 1` + if [[ $counter -gt $COUNTER_LIMIT ]] ; then + echo "Deployment does not reach staedy state with in 600 seconds. Please check" + exit 1 + fi + done + if [[ "$DEPLOYMENT_STATUS" = "Succeeded" ]] ; + then + echo "Deployment status is $DEPLOYMENT_STATUS" + else + echo "Deployment Failed. Please caheck AWS Code Deploy event logs" + exit 1 + fi + +} +# configure_aws_cli +upload_cd_pakcage +update_cd_app_revision +if [ "$DEPLOY" = "1" ] ; +then + echo "Proceeding deployment" +else + echo "User skipped deployment by updating the DEPLOY variable other than 1" + exit 0 +fi +cd_deploy +cd_deploy_status \ No newline at end of file diff --git a/deployscripts/remote-cmd-backup-app.sh b/deployscripts/remote-cmd-backup-app.sh new file mode 100755 index 00000000000..a062967b20f --- /dev/null +++ b/deployscripts/remote-cmd-backup-app.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +BACKUP_DIR=/home/web/web_backup +TARGET_JAR=${BACKUP_DIR}/topcoder.jar +BACKUP_JAR=${TARGET_JAR}.bak +# TARGET_JAR1=${BACKUP_DIR}/tc_cache.jar +# BACKUP_JAR1=${TARGET_JAR1}.bak + +# app +echo [Taking backup of existing topcoder.jar] +if [ -e $BACKUP_JAR ]; then + rm -rf $BACKUP_JAR +fi +if [ -e $TARGET_JAR ]; then + mv $TARGET_JAR $BACKUP_JAR +fi + +# echo [Taking backup of existing tc_cache.jar] +# if [ -e $BACKUP_JAR1 ]; then +# rm -rf $BACKUP_JAR1 +# fi +# if [ -e $TARGET_JAR1 ]; then +# mv $TARGET_JAR1 $BACKUP_JAR1 +# fi diff --git a/deployscripts/remote-cmd-deploy-app.sh b/deployscripts/remote-cmd-deploy-app.sh new file mode 100755 index 00000000000..2c97099b62b --- /dev/null +++ b/deployscripts/remote-cmd-deploy-app.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +source ~/.bash_profile + +pushd /home/web/web + +echo "Deploying tc-website" +ant -f build_tc.xml expand + +popd diff --git a/deployscripts/remote-cmd-expand-app.sh b/deployscripts/remote-cmd-expand-app.sh new file mode 100755 index 00000000000..783057fd1b7 --- /dev/null +++ b/deployscripts/remote-cmd-expand-app.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +source ~/.bash_profile + +WORK_DIR=/home/web/web +BACKUP_DIR=/home/web/web_backup + +BACKUP_JAR=${WORK_DIR}/topcoder.jar.bak +# BACKUP_JAR1=${WORK_DIR}/tc_cache.jar.bak + +if [ ! -e ${BACKUP_DIR}/topcoder.jar ]; then + echo "[FATAL] ${BACKUP_DIR}/topcoder.jar not found.." + exit 1; +fi +# if [ ! -e ${BACKUP_DIR}/tc_cache.jar ]; then +# echo "[FATAL] ${BACKUP_DIR}/tc_cache.jar not found.." +# exit 1; +# fi + +# +# Backup and deploy JAR +# +echo "Cleaning deployment folder ${WORK_DIR}/topcoder.jar --> $BACKUP_JAR" +if [ -e $BACKUP_JAR ]; then + rm -rf $BACKUP_JAR +fi + + +# echo "Making backup ${WORK_DIR}/tc_cache.jar --> $BACKUP_JAR" +# if [ -e $BACKUP_JAR1 ]; then +# rm -rf $BACKUP_JAR1 +# fi + +echo "Copying topcoder.jar" +cp -rf ${BACKUP_DIR}/topcoder.jar $WORK_DIR/ +# cp -rf ${BACKUP_DIR}/tc_cache.jar $WORK_DIR/ +# cp -rf ${BACKUP_DIR}/lib.zip $WORK_DIR/ +#cp -rf ${BACKUP_DIR}/resources.zip $WORK_DIR/ + +pushd $WORK_DIR +# unzip -o lib.zip +# unzip -o resources.zip +jar xvf topcoder.jar +# mkdir -p lib/jars/tcs/tc_cache/1.0.0/ +# cp -rf tc_cache.jar lib/jars/tcs/tc_cache/1.0.0/ + +popd + diff --git a/deployscripts/remote-cmd-start-server.sh b/deployscripts/remote-cmd-start-server.sh new file mode 100755 index 00000000000..d13333152c2 --- /dev/null +++ b/deployscripts/remote-cmd-start-server.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +source ~/.bash_profile + +pushd /home/web/jboss-4.0.4.GA/bin + +echo [Start Jboss] +./start.sh + +popd diff --git a/deployscripts/remote-cmd-stop-server.sh b/deployscripts/remote-cmd-stop-server.sh new file mode 100755 index 00000000000..4d7aff677de --- /dev/null +++ b/deployscripts/remote-cmd-stop-server.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +source ~/.bash_profile + +pushd /home/web/jboss-4.0.4.GA/bin + +echo [Kill Jboss] +./kill.sh + +popd diff --git a/resources/ApplicationServer.properties b/resources/ApplicationServer.properties index 0427b90772c..a04d0fde5dd 100755 --- a/resources/ApplicationServer.properties +++ b/resources/ApplicationServer.properties @@ -68,9 +68,9 @@ CONTEST_ELIGIBILITY_SERVICES_JNDI_NAME=remote/ContestEligibilityServiceBean PIPELINE_SERVICE_FACADE_USERNAME=user PIPELINE_SERVICE_FACADE_PASSWORD=password -SSO_COOKIE_KEY = tcsso_vm +SSO_COOKIE_KEY = tcsso SSO_HASH_SECRET = GKDKJF80dbdc541fe829898aa01d9e30118bab5d6b9fe94fd052a40069385f5628 -SSO_DOMAIN = topcoder.com +SSO_DOMAIN = topcoder-dev.com #Json Web Token -JWT_COOKIE_KEY = tcjwt_vm +JWT_COOKIE_KEY = tcjwt diff --git a/resources/TC.properties b/resources/TC.properties index 1d309345009..b08a95a3f34 100755 --- a/resources/TC.properties +++ b/resources/TC.properties @@ -831,4 +831,5 @@ discourse_callback_url = https://discourse.cloud.topcoder.com/session/sso_login? unactivated_user_redirect_url = http://tcqa1.wpengine.com/account-inactive/ csrf_check_referer = true -csrf_check_origin = true \ No newline at end of file +csrf_check_origin = true +login_url=https://accounts-auth0.topcoder-dev.com/ \ No newline at end of file diff --git a/resources/com/topcoder/web/tc/controller/request/docusign/docusign.xml b/resources/com/topcoder/web/tc/controller/request/docusign/docusign.xml index 8c9b3423ddf..9b0b27e91b2 100644 --- a/resources/com/topcoder/web/tc/controller/request/docusign/docusign.xml +++ b/resources/com/topcoder/web/tc/controller/request/docusign/docusign.xml @@ -75,6 +75,12 @@ handlerForVetsAgreement + + handlerForActianNDAAgreement + + + handlerForEatonNDAAgreement + @@ -247,19 +253,49 @@ - - com.topcoder.web.tc.controller.request.docusign.handlers.TermsOfUseHandler - - - - - long - - - 21263 + + com.topcoder.web.tc.controller.request.docusign.handlers.TermsOfUseHandler + + + + + long + + + 21263 + - + + + com.topcoder.web.tc.controller.request.docusign.handlers.TermsOfUseHandler + + + + + long + + + 21283 + + + + + + + com.topcoder.web.tc.controller.request.docusign.handlers.TermsOfUseHandler + + + + + long + + + 21313 + + + + diff --git a/scripts/dde/RatingQubits.xml b/scripts/dde/RatingQubits.xml index 2d1a48df26a..ca43fe4ce1c 100755 --- a/scripts/dde/RatingQubits.xml +++ b/scripts/dde/RatingQubits.xml @@ -9,4 +9,13 @@ 300 + + 150 + 149 + + + 06/01/2010 06:06:06 + NULL + + diff --git a/src/main/com/topcoder/dde/util/DWLoad/RatingQubits.java b/src/main/com/topcoder/dde/util/DWLoad/RatingQubits.java index 14135147452..c34b308b44b 100755 --- a/src/main/com/topcoder/dde/util/DWLoad/RatingQubits.java +++ b/src/main/com/topcoder/dde/util/DWLoad/RatingQubits.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 - 2009 TopCoder Inc., All Rights Reserved. + * Copyright (C) 2004 - 2018 TopCoder Inc., All Rights Reserved. */ package com.topcoder.dde.util.DWLoad; @@ -13,10 +13,7 @@ import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.TreeMap; -import java.util.Vector; +import java.util.*; import com.topcoder.shared.util.DBMS; import com.topcoder.shared.util.logging.Logger; @@ -42,8 +39,15 @@ * *

* - * @author pulky, VolodymyrK - * @version 1.2 + *

+ * Version 1.3 Change notes(Topcoder - Support Rating and Reliability Generation For Code Challenges in DWLoad): + *

    + *
  1. Added support for code challenge and load phase ids, cutoffs configurations from file.
  2. + *
+ *

+ * + * @author pulky, VolodymyrK,TCCODER + * @version 1.3 */ public class RatingQubits { private static final Logger log = Logger.getLogger(RatingQubits.class); @@ -52,6 +56,34 @@ public class RatingQubits { public static final String CONNECTION_URL_KEY = "ConnectionURL"; public static final String HISTORY_LENGTH_KEY = "HistoryLength"; + /** + * Property key name for phase ids + * + * @since 1.3 + */ + private static final String PHASE_IDS_KEY = "PhaseIds"; + + /** + * Property key name for cutoffs + * + * @since 1.3 + */ + private static final String CUT_OFFS_KEY = "CutOffs"; + + /** + * Property value for null value of cutoff + * + * @since 1.3 + */ + private static final String NULL_CUT_OFF = "null"; + + /** + * The simple date format for cut off. + * + * @since 1.3 + */ + private static final SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + private static final String NEW_PHASES_CUT_OFF = "03/23/2009 00:00:00"; private static final String UI_PROTOTYPE_CUT_OFF = "08/01/2009 00:00:00"; private static final String RIA_BUILD_CUT_OFF = "06/01/2010 00:00:00"; @@ -68,26 +100,37 @@ public class RatingQubits { private static final int RIA_BUILDS_PHASE_ID = 135; private static final int CONTENT_CREATION_PHASE_ID = 146; private static final int REPORTING_PHASE_ID = 147; + /** + * Code challenge phase id. + * + * @since 1.3 + */ + private static final int CODE_PHASE_ID = 150; private final static String NEW_RATING_STATUSES = "(4, 7, 8)"; /** * SQL fragment to be added to a where clause to not select projects with eligibility constraints - * + * * @since 1.1 */ private static final String ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT = " and p.project_id not in (select ce.contest_id from contest_eligibility ce " + - " where ce.is_studio = 0) "; + " where ce.is_studio = 0) "; /** * SQL fragment to be added to a where clause to select only rated projects - * + * * @since 1.2 */ private static final String RATED_CONSTRAINTS_SQL_FRAGMENT = " and p.project_id in (select pi.project_id from project_info pi where pi.project_info_type_id=13 " + - "and (pi.value='Yes' or pi.value='yes')) "; + "and (pi.value='Yes' or pi.value='yes')) "; + /** + * Load phase ids and cutoffs configurations from file + * @param args the command arguments + * @since 1.3 + */ public static void main(String[] args) { RatingQubits tmp = new RatingQubits(); @@ -113,6 +156,7 @@ public static void main(String[] args) { String jdbcDriver; String connectionURL; + Map projects = new HashMap(); try { jdbcDriver = config.getString(namespace, DRIVER_KEY); connectionURL = config.getString(namespace, CONNECTION_URL_KEY); @@ -126,6 +170,42 @@ public static void main(String[] args) { System.err.println("No Connection URL specified. (Config param '" + CONNECTION_URL_KEY + "')"); return; } + String[] phaseIds = config.getStringArray(namespace, PHASE_IDS_KEY); + String[] cutOffs = config.getStringArray(namespace, CUT_OFFS_KEY); + if (phaseIds!= null && cutOffs !=null) { + if (phaseIds.length != cutOffs.length) { + System.err.println("(Config param '" + PHASE_IDS_KEY + "')(" + phaseIds.length + ") and (Config param '" + + CUT_OFFS_KEY + "')("+ cutOffs.length + ") should have same length of string array"); + return; + } + for (int i = 0; i < phaseIds.length; i++) { + String id = phaseIds[i]; + int phaseId = -1; + try { + phaseId = Integer.parseInt(id); + } catch (NumberFormatException e) { + System.err.println("Invalid phase id value for "+ id + ", please check it"); + return; + } + if (projects.containsKey(phaseId)) { + System.err.println("(Config param '" + PHASE_IDS_KEY + "') contains duplicated phase id "+id); + return; + } + String cutoff = cutOffs[i]; + + Date cutoffDate = null; + try { + if (!NULL_CUT_OFF.equalsIgnoreCase(cutoff)){ + cutoffDate = new Date(SDF.parse(cutoff).getTime()); + } + } catch (ParseException e) { + e.printStackTrace(); + System.err.println("Invalid cutoff value " + cutoff + "for phase id "+ phaseId + ", please check it"); + return; + } + projects.put(phaseId, cutoffDate); + } + } } catch (UnknownNamespaceException e) { System.err.println("Initialized ConfigManager and namespace '" + namespace + "' without trouble but could not retrieve resource bundle"); return; @@ -137,7 +217,7 @@ public static void main(String[] args) { c = DriverManager.getConnection(connectionURL); c.setAutoCommit(true); - tmp.runAllScores(c, historyLength); + tmp.runAllScores(c, historyLength, projects); } catch (Exception e) { e.printStackTrace(); } finally { @@ -149,13 +229,18 @@ public static void main(String[] args) { } } - public void runAllScores(Connection conn, String historyLength) { - - SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + /** + * Run all score + * @param conn the database connection + * @param historyLength the length of history + * @param projects the projects map with keyis phase id and value is cut off date + * @since 1.3 + */ + public void runAllScores(Connection conn, String historyLength, Map projects) { Date newPhasesCutoff = null; try { - newPhasesCutoff = new Date(sdf.parse(NEW_PHASES_CUT_OFF).getTime()); + newPhasesCutoff = new Date(SDF.parse(NEW_PHASES_CUT_OFF).getTime()); } catch (ParseException e1) { System.err.println("Invalid value for constant NEW_PHASES_CUT_OFF, please check it"); return; @@ -163,7 +248,7 @@ public void runAllScores(Connection conn, String historyLength) { Date uiPrototypeCutoff = null; try { - uiPrototypeCutoff = new Date(sdf.parse(UI_PROTOTYPE_CUT_OFF).getTime()); + uiPrototypeCutoff = new Date(SDF.parse(UI_PROTOTYPE_CUT_OFF).getTime()); } catch (ParseException e1) { System.err.println("Invalid value for constant UI_PROTOTYPE_CUT_OFF, please check it"); return; @@ -171,24 +256,43 @@ public void runAllScores(Connection conn, String historyLength) { Date riaBuildCutoff = null; try { - riaBuildCutoff = new Date(sdf.parse(RIA_BUILD_CUT_OFF).getTime()); + riaBuildCutoff = new Date(SDF.parse(RIA_BUILD_CUT_OFF).getTime()); } catch (ParseException e1) { System.err.println("Invalid value for constant RIA_BUILD_CUT_OFF, please check it"); return; } - runScore(conn, historyLength, DESIGN_PHASE_ID); - runScore(conn, historyLength, DEV_PHASE_ID); - runScore(conn, historyLength, ASSEMBLY_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, ARCHITECTURE_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, SPECIFICATION_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, CONCEPTUALIZATION_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, TESTING_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, TEST_SCENARIOS_PHASE_ID, newPhasesCutoff); - runScore(conn, historyLength, UI_PROTOTYPES_PHASE_ID, uiPrototypeCutoff); - runScore(conn, historyLength, RIA_BUILDS_PHASE_ID, riaBuildCutoff); - runScore(conn, historyLength, CONTENT_CREATION_PHASE_ID, riaBuildCutoff); - runScore(conn, historyLength, REPORTING_PHASE_ID, riaBuildCutoff); + for (Map.Entry entry : projects.entrySet()) { + runScore(conn, historyLength, entry.getKey(), entry.getValue()); + } + // phase ids without cut off + int[] phaseIds1 = new int [] { DESIGN_PHASE_ID, DEV_PHASE_ID } ; + for (int i = 0; i < phaseIds1.length; i++) { + if(!projects.containsKey(phaseIds1[i])) { + runScore(conn, historyLength, phaseIds1[i]); + } + } + + // phase ids with newPhasesCutoff + int[] phaseIds2 = new int [] { ASSEMBLY_PHASE_ID, ARCHITECTURE_PHASE_ID, SPECIFICATION_PHASE_ID, + CONCEPTUALIZATION_PHASE_ID, TESTING_PHASE_ID, TEST_SCENARIOS_PHASE_ID } ; + for (int i = 0; i < phaseIds2.length; i++) { + if(!projects.containsKey(phaseIds2[i])) { + runScore(conn, historyLength, phaseIds2[i], newPhasesCutoff); + } + } + + if (!projects.containsKey(UI_PROTOTYPES_PHASE_ID)) { + runScore(conn, historyLength, UI_PROTOTYPES_PHASE_ID, uiPrototypeCutoff); + } + + // phase ids with riaBuildCutoff + int[] phaseIds3 = new int [] { RIA_BUILDS_PHASE_ID, CONTENT_CREATION_PHASE_ID, REPORTING_PHASE_ID, CODE_PHASE_ID } ; + for (int i = 0; i < phaseIds3.length; i++) { + if(!projects.containsKey(phaseIds3[i])) { + runScore(conn, historyLength, phaseIds3[i], riaBuildCutoff); + } + } } // Run a score without a specific cut off time @@ -203,8 +307,11 @@ private void runScore(Connection conn, String historyLength, int phase) { * @param historyLength the history length * @param phase the phase * @param cutoff the cutoff date + * @since 1.3 */ private void runScore(Connection conn, String historyLength, int phase, Date cutoff) { + System.out.println("Run score for historyLength " + historyLength + " phase " + phase + + " cutoff " + ( cutoff == null ? NULL_CUT_OFF : SDF.format(cutoff))); PreparedStatement ps = null; ResultSet rs = null; @@ -216,7 +323,7 @@ private void runScore(Connection conn, String historyLength, int phase, Date cut "case when substr(pi_rd.value, 18,2)='PM' then round(substr(pi_rd.value, 12, 2)) +12 else round(substr(pi_rd.value, 12, 2)) end as hour " + "from project_result pr, project p, project_info pi_rd " ; if (cutoff != null) { - sqlStr += ", project_phase pp "; + sqlStr += ", project_phase pp "; } sqlStr += "where p.project_id = pr.project_id " + "and p.project_status_id in " + NEW_RATING_STATUSES + " " + @@ -227,11 +334,10 @@ private void runScore(Connection conn, String historyLength, int phase, Date cut RATED_CONSTRAINTS_SQL_FRAGMENT + "and pi_rd.project_id = p.project_id and pi_rd.project_info_type_id = 22 "; if (cutoff != null) { - sqlStr += "and pp.project_id = p.project_id and pp.phase_type_id = 1 " + - "and pp.actual_start_time > ? "; + sqlStr += "and pp.project_id = p.project_id and pp.phase_type_id = 1 " + + "and pp.actual_start_time > ? "; } sqlStr += "order by year, month, day, hour, 1"; - ps = conn.prepareStatement(sqlStr); ps.setInt(1, phase - 111); // Project Category if (cutoff != null) { @@ -969,13 +1075,13 @@ private double normsinv(double p) { private double normsinvnew(double p) { /* ******************************************** - * Original algorythm and Perl implementation can - * be found at: - * http://www.math.uio.no/~jacklam/notes/invnorm/index.html - * Author: - * Peter J. Acklam - * jacklam@math.uio.no - * ****************************************** */ + * Original algorythm and Perl implementation can + * be found at: + * http://www.math.uio.no/~jacklam/notes/invnorm/index.html + * Author: + * Peter J. Acklam + * jacklam@math.uio.no + * ****************************************** */ // Define break-points. // variable for result @@ -1107,4 +1213,3 @@ private double winprobability(double meana, double stddeva, double meanb, double //----------------------END RATING FUNCTIONS0----------------------------------------------- } - diff --git a/src/main/com/topcoder/utilities/dwload/TCLoadTCS.java b/src/main/com/topcoder/utilities/dwload/TCLoadTCS.java index 6c4629eb4f6..cb4b6ce5e02 100755 --- a/src/main/com/topcoder/utilities/dwload/TCLoadTCS.java +++ b/src/main/com/topcoder/utilities/dwload/TCLoadTCS.java @@ -21,17 +21,9 @@ import java.sql.Timestamp; import java.sql.Types; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; +import java.util.*; /** *

Purpose: @@ -206,7 +198,7 @@ public class TCLoadTCS extends TCLoad { *

A String representing all those project categories than should be loaded to the * data warehouse.

*/ - private static final String LOAD_CATEGORIES = "(1, 2, 5, 6, 7, 13, 14, 23, 19, 24, 25, 26, 29, 35, 16, 17, 18, 20, 21, 30, 31, 32, 34, 22, 36, 9, 39, 38, 40)"; + private static final String LOAD_CATEGORIES = "(1, 2, 5, 6, 7, 13, 14, 23, 19, 24, 25, 26, 29, 35, 16, 17, 18, 20, 21, 30, 31, 32, 34, 22, 36, 9, 39, 38, 40, 37)"; /** *

An int array representing all project categories that are currently being rated. @@ -262,6 +254,15 @@ public class TCLoadTCS extends TCLoad { " and p.project_id not in (select ce.contest_id from contest_eligibility ce " + " where ce.is_studio = 0) "; + /** + * SQL fragment to be added to a where clause to select projects with eligibility constraints + * + * @since 1.1.5 + */ + private static final String WITH_ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT = + " and p.project_id in (select ce.contest_id from contest_eligibility ce " + + " where ce.is_studio = 0) "; + /** * Confirmed status. * @@ -294,6 +295,10 @@ public TCLoadTCS() { private String submissionDir = null; + private Boolean fullLoad = false; + + private List dateFilterBatches = null; + /** * Return if it will load moved project which not be covered by last old_dw load. * @@ -320,6 +325,30 @@ public boolean setParameters(Hashtable params) { submissionDir = temp; } + String fullLoadStr = (String) params.get("full_load"); + if (fullLoadStr!=null){ + fullLoad = fullLoadStr.equals("true"); + if(fullLoad) { + System.out.println("Prepare for Full Load"); + dateFilterBatches = new ArrayList(); + try { + int batchDays = Integer.parseInt((String) params.get("batch_size_days")); + java.util.Date startDate = DATE_FORMATS[0].parse("01/01/2000 00:00"); + java.util.Date now = new java.util.Date(); + Calendar cal = Calendar.getInstance(); + while (startDate.getTime() * Load projects to the DW. @@ -1500,7 +1552,7 @@ private void loadNewColumns3ForProjectFirstTime() throws Exception { * * @throws Exception if any error occurs */ - public void doLoadProjects() throws Exception { + public void doLoadProjects(String eligibilityConstraint, String targetTable, Timestamp startTime, Timestamp endTime) throws Exception { log.info("load projects"); PreparedStatement select = null; PreparedStatement update = null; @@ -1512,14 +1564,14 @@ public void doLoadProjects() throws Exception { //log.debug("PROCESSING PROJECT " + project_id); long start = System.currentTimeMillis(); - loadNewColumnsForProjectFirstTime(); + loadNewColumnsForProjectFirstTime(targetTable); - loadNewColumns2ForProjectFirstTime(); + loadNewColumns2ForProjectFirstTime(targetTable); - loadNewColumns3ForProjectFirstTime(); + loadNewColumns3ForProjectFirstTime(targetTable); //get data from source DB - final String SELECT = + String SELECT = "select p.project_id " + " ,cc.component_id " + " ,cc.component_name " + @@ -1676,7 +1728,7 @@ public void doLoadProjects() throws Exception { " AND NOT pmd2.payment_status_id IN (65, 68, 69)), 0)) as review_cost" + ", (SELECT value::INTEGER FROM project_info piforum WHERE piforum.project_id = p.project_id and piforum.project_info_type_id = 4) as forum_id" + ", (select CASE when pi53.value == 'true' THEN 1 ELSE 0 END FROM project_info pi53 where pi53.project_info_type_id = 53 and pi53.project_id = p.project_id) as submission_viewable" + - ", NVL((SELECT 1 FROM contest_eligibility WHERE contest_id = p.project_id), 0) AS is_private" + + ", NVL((SELECT MIN(1) FROM contest_eligibility WHERE contest_id = p.project_id), 0) AS is_private" + // estimated_reliability_cost ",(CASE WHEN pire.value = 'true' THEN NVL((SELECT value::decimal FROM project_info pi38 WHERE pi38.project_id = p.project_id AND pi38.project_info_type_id = 38), 0) ELSE 0 END) as estimated_reliability_cost" + @@ -1763,7 +1815,7 @@ public void doLoadProjects() throws Exception { " and piaf.project_info_type_id = 31 " + " and pib.project_id = p.project_id " + " and pib.project_info_type_id = 32 and pib.value > 0 " + - ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT + + eligibilityConstraint + " and cc.component_id = pir.value " + " and cc.root_category_id = cat.category_id " + " and psl.project_status_id = p.project_status_id " + @@ -1779,24 +1831,30 @@ public void doLoadProjects() throws Exception { // we need to process deleted project, otherwise there's a possibility // they will keep living in the DW. //" and p.project_status_id <> 3 " + - " and p.project_category_id in " + LOAD_CATEGORIES + - " and (p.modify_date > ? " + - // comp versions with modified date - " or cv.modify_date > ? " + - // add projects who have modified resources - " or p.project_id in (select distinct r.project_id from resource r where (r.create_date > ? or r.modify_date > ?)) " + - // add projects who have modified upload and submissions - " or p.project_id in (select distinct u.project_id from upload u, submission s where s.submission_type_id = 1 and u.upload_id = s.upload_id and " + - " (u.create_date > ? or u.modify_date > ? or s.create_date > ? or s.modify_date > ?)) " + - // add projects who have modified results - " or p.project_id in (select distinct pr.project_id from project_result pr where (pr.create_date > ? or pr.modify_date > ?)) " + - " or p.project_id in (select distinct pi.project_id from project_info pi where project_info_type_id in (2, 3, 21, 22, 23, 26, 31, 32, 33, 38, 45, 49) and (pi.create_date > ? or pi.modify_date > ?)) " + - " or p.project_id in (select distinct pmd.component_project_id::int " + - " FROM informixoltp:payment pm INNER JOIN informixoltp:payment_detail pmd ON pm.most_recent_detail_id = pmd.payment_detail_id " + - " WHERE NOT pmd.payment_status_id IN (65, 69) AND (pmd.create_date > ? or pmd.date_modified > ? or pm.create_date > ? or pm.modify_date > ?)) " + - (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' OR pir.modify_user <> 'Converter' )" : ")"); + " and p.project_category_id in " + LOAD_CATEGORIES; + + if (endTime==null){ + SELECT += " and (p.modify_date > ? " + + // comp versions with modified date + " or cv.modify_date > ? " + + // add projects who have modified resources + " or p.project_id in (select distinct r.project_id from resource r where (r.create_date > ? or r.modify_date > ?)) " + + // add projects who have modified upload and submissions + " or p.project_id in (select distinct u.project_id from upload u, submission s where s.submission_type_id = 1 and u.upload_id = s.upload_id and " + + " (u.create_date > ? or u.modify_date > ? or s.create_date > ? or s.modify_date > ?)) " + + // add projects who have modified results + " or p.project_id in (select distinct pr.project_id from project_result pr where (pr.create_date > ? or pr.modify_date > ?)) " + + " or p.project_id in (select distinct pi.project_id from project_info pi where project_info_type_id in (2, 3, 21, 22, 23, 26, 31, 32, 33, 38, 45, 49) and (pi.create_date > ? or pi.modify_date > ?)) " + + " or p.project_id in (select distinct pmd.component_project_id::int " + + " FROM informixoltp:payment pm INNER JOIN informixoltp:payment_detail pmd ON pm.most_recent_detail_id = pmd.payment_detail_id " + + " WHERE NOT pmd.payment_status_id IN (65, 69) AND (pmd.create_date > ? or pmd.date_modified > ? or pm.create_date > ? or pm.modify_date > ?)) " + + (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' OR pir.modify_user <> 'Converter' )" : ")"); + } else { + SELECT += " and (p.create_date >= ? and p.create_date < ?)"; + } - final String UPDATE = "update project set component_name = ?, num_registrations = ?, " + + + final String UPDATE = "update " + targetTable + " set component_name = ?, num_registrations = ?, " + "num_submissions = ?, num_valid_submissions = ?, avg_raw_score = ?, avg_final_score = ?, " + "phase_id = ?, phase_desc = ?, category_id = ?, category_desc = ?, posting_date = ?, submitby_date " + "= ?, complete_date = ?, component_id = ?, review_phase_id = ?, review_phase_name = ?, " + @@ -1812,7 +1870,7 @@ public void doLoadProjects() throws Exception { "estimated_reliability_cost = ?, estimated_review_cost = ?, estimated_copilot_cost = ?, estimated_admin_fee = ?, actual_total_prize = ?, copilot_cost = ?" + "where project_id = ? "; - final String INSERT = "insert into project (project_id, component_name, num_registrations, num_submissions, " + + final String INSERT = "insert into " + targetTable + " (project_id, component_name, num_registrations, num_submissions, " + "num_valid_submissions, avg_raw_score, avg_final_score, phase_id, phase_desc, " + "category_id, category_desc, posting_date, submitby_date, complete_date, component_id, " + "review_phase_id, review_phase_name, status_id, status_desc, level_id, viewable_category_ind, version_id, " + @@ -1832,35 +1890,41 @@ public void doLoadProjects() throws Exception { "?, ?, current, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; // Statements for updating the duration, fulfillment, start_date_calendar_id fields - final String UPDATE_AGAIN = "UPDATE project SET " + + final String UPDATE_AGAIN = "UPDATE " + targetTable + " SET " + "fulfillment = (CASE WHEN status_id = 7 THEN 1 ELSE 0 END), " + - "start_date_calendar_id = (SELECT calendar_id FROM calendar c WHERE YEAR(project.posting_date) = c.year " + - " AND MONTH(project.posting_date) = c.month_numeric " + - " AND DAY(project.posting_date) = c.day_of_month) " + + "start_date_calendar_id = (SELECT calendar_id FROM calendar c WHERE YEAR("+targetTable+".posting_date) = c.year " + + " AND MONTH("+targetTable+".posting_date) = c.month_numeric " + + " AND DAY("+targetTable+".posting_date) = c.day_of_month) " + "WHERE complete_date IS NOT NULL AND tc_direct_project_id > 0 AND posting_date IS NOT NULL"; select = prepareStatement(SELECT, SOURCE_DB); - select.setTimestamp(1, fLastLogTime); - select.setTimestamp(2, fLastLogTime); - select.setTimestamp(3, fLastLogTime); - select.setTimestamp(4, fLastLogTime); - select.setTimestamp(5, fLastLogTime); - select.setTimestamp(6, fLastLogTime); - select.setTimestamp(7, fLastLogTime); - select.setTimestamp(8, fLastLogTime); - select.setTimestamp(9, fLastLogTime); - select.setTimestamp(10, fLastLogTime); - select.setTimestamp(11, fLastLogTime); - select.setTimestamp(12, fLastLogTime); - select.setTimestamp(13, fLastLogTime); - select.setTimestamp(14, fLastLogTime); - select.setTimestamp(15, fLastLogTime); - select.setTimestamp(16, fLastLogTime); + if (endTime==null) { + select.setTimestamp(1, startTime); + select.setTimestamp(2, startTime); + select.setTimestamp(3, startTime); + select.setTimestamp(4, startTime); + select.setTimestamp(5, startTime); + select.setTimestamp(6, startTime); + select.setTimestamp(7, startTime); + select.setTimestamp(8, startTime); + select.setTimestamp(9, startTime); + select.setTimestamp(10, startTime); + select.setTimestamp(11, startTime); + select.setTimestamp(12, startTime); + select.setTimestamp(13, startTime); + select.setTimestamp(14, startTime); + select.setTimestamp(15, startTime); + select.setTimestamp(16, startTime); + } else { + select.setTimestamp(1, startTime); + select.setTimestamp(2, endTime); + } update = prepareStatement(UPDATE, TARGET_DB); insert = prepareStatement(INSERT, TARGET_DB); updateAgain = prepareStatement(UPDATE_AGAIN, TARGET_DB); rs = select.executeQuery(); int count = 0; + int insertCount = 0; while (rs.next()) { if (rs.getLong("project_stat_id") != DELETED_PROJECT_STATUS) { @@ -2016,7 +2080,7 @@ public void doLoadProjects() throws Exception { update.setLong(62, rs.getLong("project_id")); - System.out.println("------------project id --------------------------"+rs.getLong("project_id")); + //log.info("------------project id --------------------------"+rs.getLong("project_id")); int retVal = update.executeUpdate(); @@ -2143,6 +2207,8 @@ public void doLoadProjects() throws Exception { insert.setDouble(62, rs.getDouble("copilot_cost")); insert.executeUpdate(); + insertCount++; + } } else { // we need to delete this project and all related objects in the database. @@ -2154,6 +2220,7 @@ public void doLoadProjects() throws Exception { // update the start_date_calendar_id, duration, fulfillment fields updateAgain.executeUpdate(); + log.info("--------------Inserted " + insertCount + " records in " + targetTable + "--------------"); log.info("loaded " + count + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds"); } catch (SQLException sqle) { @@ -2171,7 +2238,6 @@ public void doLoadProjects() throws Exception { } } - /** *

* Load Marathon Matches to the DW. @@ -2717,7 +2783,7 @@ public void doLoadProjectTechnologies() throws Exception { String name = rs.getString("technology_name"); if(!firstRun && !deletedProjects.contains(projectID)) { - // the load is not run for the first time && it's not processed in this load, clear the old technologies for the project + // the load is not run for the first time && it's not processed in this load, clear the old groups for the project deleteTechnologies.clearParameters(); deleteTechnologies.setLong(1, projectID); deleteTechnologies.executeUpdate(); @@ -2750,6 +2816,93 @@ public void doLoadProjectTechnologies() throws Exception { } } + /** + * Loads the project groups. + * + * @throws Exception if any error. + * @since 1.2.3 + */ + public void doLoadProjectGroups() throws Exception { + log.info("load project groups"); + + PreparedStatement firstTimeSelect = null; + PreparedStatement deleteGroups = null; + PreparedStatement selectGroups = null; + PreparedStatement insertGroups = null; + ResultSet rs = null; + Set deletedProjects = new HashSet(); + + try { + long start = System.currentTimeMillis(); + + firstTimeSelect = prepareStatement("SELECT count(*) from project_groups", TARGET_DB); + rs = firstTimeSelect.executeQuery(); + rs.next(); + + // no records, it's the first run of loading groups + boolean firstRun = rs.getInt(1) == 0; + + if(firstRun) log.info("Loading project group table for the first time. A complete load will be performed"); + + final String SELECT = "select p.project_id, group_id from project p INNER JOIN common_oltp:contest_eligibility ce ON ce.contest_id = p.project_id INNER JOIN common_oltp:group_contest_eligibility gce ON gce.contest_eligibility_id=ce.contest_eligibility_id \n" + + (firstRun ? "" : " AND (p.create_date > ? OR p.modify_date > ?)") + + "group by p.project_id, group_id"; + + selectGroups = prepareStatement(SELECT, SOURCE_DB); + + if(!firstRun) { + // no the first time, set last loading time + selectGroups.setTimestamp(1, fLastLogTime); + selectGroups.setTimestamp(2, fLastLogTime); + } + + + final String DELETE = "delete from project_groups where project_id = ?"; + deleteGroups = prepareStatement(DELETE, TARGET_DB); + + final String INSERT = "insert into project_groups (project_id, group_id) VALUES (?,?)"; + insertGroups = prepareStatement(INSERT, TARGET_DB); + + rs = selectGroups.executeQuery(); + + int countRecords = 0; + + while (rs.next()) { + long projectID = rs.getLong("project_id"); + long groupId = rs.getLong("group_id"); + + if(!firstRun && !deletedProjects.contains(projectID)) { + // the load is not run for the first time && it's not processed in this load, clear the old technologies for the project + deleteGroups.clearParameters(); + deleteGroups.setLong(1, projectID); + deleteGroups.executeUpdate(); + deletedProjects.add(projectID); + } + + insertGroups.clearParameters(); + insertGroups.setLong(1, projectID); + insertGroups.setLong(2, groupId); + + insertGroups.executeUpdate(); + countRecords ++; + } + + log.info("Loaded " + countRecords + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds"); + + } catch(SQLException sqle) { + DBMS.printSqlException(true, sqle); + throw new Exception("Load Project groups failed.\n" + + sqle.getMessage()); + } finally { + close(rs); + close(firstTimeSelect); + close(selectGroups); + close(deleteGroups); + close(insertGroups); + deletedProjects.clear(); + } + } + /** * Helper method that deletes all project related objects in the dw. * @@ -2771,11 +2924,14 @@ private void deleteProject(long projectId) throws SQLException { simpleDelete("submission", "project_id", projectId); simpleDelete("appeal", "project_id", projectId); simpleDelete("project_result", "project_id", projectId); + simpleDelete("private_project_result", "project_id", projectId); simpleDelete("design_project_result", "project_id", projectId); + simpleDelete("private_design_project_result", "project_id", projectId); simpleDelete("project_spec_review_xref", "project_id", projectId); simpleDelete("project_platform", "project_id", projectId); simpleDelete("project_technology", "project_id", projectId); simpleDelete("project", "project_id", projectId); + simpleDelete("private_project", "project_id", projectId); } /** @@ -2930,6 +3086,20 @@ private Map getDRProjects() throws Exception { return dRProjects; } + public void doLoadPublicProjectResults() throws Exception { + doLoadProjectResults(ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "project_result", fLastLogTime, null); + } + + public void doLoadPrivateProjectResults() throws Exception { + if (fullLoad) { + for (int i = 0; i < dateFilterBatches.size() - 1; i++) { + doLoadProjectResults(WITH_ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "private_project_result", dateFilterBatches.get(i), dateFilterBatches.get(i + 1)); + } + } else{ + doLoadProjectResults(WITH_ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "private_project_result", fLastLogTime, null); + } + } + /** *

* Load projects results to the DW. @@ -2937,7 +3107,7 @@ private Map getDRProjects() throws Exception { * * @throws Exception if any error occurs */ - public void doLoadProjectResults() throws Exception { + public void doLoadProjectResults(String eligibilityConstraint, String targetTable, Timestamp startTime, Timestamp endTime) throws Exception { log.info("load project results"); ResultSet projectResults = null; PreparedStatement projectSelect = null; @@ -2953,30 +3123,42 @@ public void doLoadProjectResults() throws Exception { ResultSet projects = null; ResultSet dwData = null; - final String PROJECTS_SELECT = - "select distinct pr.project_id " + - "from project_result pr, " + - "project p, " + + String PROJECTS_SELECT = + "select distinct p.project_id " + + "from project p "; + + if(endTime == null) { + PROJECTS_SELECT+= + ", project_result pr, " + "project_info pi, " + "comp_versions cv, " + - "comp_catalog cc " + - "where p.project_id = pr.project_id " + - "and p.project_id = pi.project_id " + - "and p.project_status_id <> 3 " + - "and p.project_category_id in " + LOAD_CATEGORIES + - "and pi.project_info_type_id = 1 " + - "and cv.comp_vers_id= pi.value " + - "and cc.component_id = cv.component_id " + - ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT + - "and (p.modify_date > ? " + - " OR cv.modify_date > ? " + - " OR pi.modify_date > ? " + - " OR cc.modify_date > ? " + - " OR pr.modify_date > ?" + - (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' " + - " OR pi.modify_user <> 'Converter' " + - ")" - : ")"); + "comp_catalog cc "; + + } + PROJECTS_SELECT+= "where p.project_status_id <> 3" + + "and p.project_category_id in " + LOAD_CATEGORIES + + eligibilityConstraint; + if (endTime==null){ + PROJECTS_SELECT+= + "and p.project_id = pi.project_id " + + "and p.project_id = pr.project_id " + + "and pi.project_info_type_id = 1 " + + "and cv.comp_vers_id= pi.value " + + "and cc.component_id = cv.component_id " + + "and (p.modify_date > ? " + + " OR cv.modify_date > ? " + + " OR pi.modify_date > ? " + + " OR cc.modify_date > ? " + + " OR pr.modify_date > ?" + + (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' " + + " OR pi.modify_user <> 'Converter' " + + ")" + : ")"); + } else { + PROJECTS_SELECT+= + "and (p.create_date >= ? and p.create_date < ?)"; + } + final String RESULT_SELECT = "SELECT DISTINCT pr.project_id, " + " pr.user_id, " + @@ -3238,7 +3420,7 @@ public void doLoadProjectResults() throws Exception { // " and pre.user_id = pr.user_id"; final String RESULT_INSERT = - "insert into project_result (project_id, user_id, submit_ind, valid_submission_ind, raw_score, final_score, inquire_timestamp," + + "insert into " + targetTable + " (project_id, user_id, submit_ind, valid_submission_ind, raw_score, final_score, inquire_timestamp," + " submit_timestamp, review_complete_timestamp, payment, old_rating, new_rating, old_reliability, new_reliability, placed, rating_ind, " + " passed_review_ind, points_awarded, final_points, reliable_submission_ind, old_rating_id, " + "new_rating_id, num_ratings, rating_order, potential_points) " + @@ -3257,7 +3439,7 @@ public void doLoadProjectResults() throws Exception { " where project_id = ? " + " and user_id = ?"; final String DW_DATA_UPDATE = - "update project_result set num_appeals = ?, num_successful_appeals = ? where project_id = ? and user_id = ?"; + "update " + targetTable + " set num_appeals = ?, num_successful_appeals = ? where project_id = ? and user_id = ?"; final String NUM_RATINGS = " select count(*) as count " + @@ -3279,11 +3461,16 @@ public void doLoadProjectResults() throws Exception { Map dRProjects = getDRProjects(); projectSelect = prepareStatement(PROJECTS_SELECT, SOURCE_DB); - projectSelect.setTimestamp(1, fLastLogTime); - projectSelect.setTimestamp(2, fLastLogTime); - projectSelect.setTimestamp(3, fLastLogTime); - projectSelect.setTimestamp(4, fLastLogTime); - projectSelect.setTimestamp(5, fLastLogTime); + if (endTime == null) { + projectSelect.setTimestamp(1, startTime); + projectSelect.setTimestamp(2, startTime); + projectSelect.setTimestamp(3, startTime); + projectSelect.setTimestamp(4, startTime); + projectSelect.setTimestamp(5, startTime); + } else { + projectSelect.setTimestamp(1, startTime); + projectSelect.setTimestamp(2, endTime); + } resultInsert = prepareStatement(RESULT_INSERT, TARGET_DB); drInsert = prepareStatement(DR_POINTS_INSERT, SOURCE_DB); @@ -3304,7 +3491,7 @@ public void doLoadProjectResults() throws Exception { buf.append(" and p.project_id in ("); StringBuffer delQuery = new StringBuffer(300); - delQuery.append("delete from project_result where project_id in ("); + delQuery.append("delete from " + targetTable + " where project_id in ("); StringBuffer delDrPointsQuery = new StringBuffer(300); delDrPointsQuery.append("delete from dr_points where dr_points_reference_type_id = 1 and reference_id in ("); @@ -3336,8 +3523,10 @@ public void doLoadProjectResults() throws Exception { delete.executeUpdate(); // delete dr points for these projects. - deleteDrPoints = prepareStatement(delDrPointsQuery.toString(), SOURCE_DB); - deleteDrPoints.executeUpdate(); + // Jan 17, 2018 Remove the Delete DR points query to source database + // Source Db is TCS Mirror which is read only + //deleteDrPoints = prepareStatement(delDrPointsQuery.toString(), SOURCE_DB); + //deleteDrPoints.executeUpdate(); // get max dr points id @@ -3454,7 +3643,8 @@ public void doLoadProjectResults() throws Exception { drInsert.setBoolean(9, false); log.debug("Inserting DR points: " + t.getTrackId() + " - " + pr.getUserId() + " - " + pointsAwarded + " (" + projectResults.getInt("point_adjustment") + ")"); - drInsert.executeUpdate(); + //18th Jan, 2019, remove updates to source database, as its mirror + //drInsert.executeUpdate(); } else { log.debug("Awarded 0 points: " + t.getTrackId() + " - " + pr.getUserId() + " - " + pointsAwarded + " (" + projectResults.getInt("point_adjustment") + ")"); @@ -3474,7 +3664,8 @@ public void doLoadProjectResults() throws Exception { drInsert.setBoolean(9, true); log.debug("Inserting DR points: " + t.getTrackId() + " - " + pr.getUserId() + " - " + potentialPoints + " (" + projectResults.getInt("point_adjustment") + ")"); - drInsert.executeUpdate(); + //18th Jan, 2019, remove updates to source database, as its mirror + //drInsert.executeUpdate(); } else { log.debug("Potential 0 points: " + t.getTrackId() + " - " + pr.getUserId() + " - " + potentialPoints + " (" + projectResults.getInt("point_adjustment") + ")"); @@ -3579,9 +3770,9 @@ public void doLoadProjectResults() throws Exception { } } - log.info("loaded " + count + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds"); + log.info("loaded " + count + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds" + " table: " + targetTable); } else { - log.info("loaded " + 0 + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds"); + log.info("loaded " + 0 + " records in " + (System.currentTimeMillis() - start) / 1000 + " seconds" + " table: " + targetTable); } } finally { close(delete); @@ -3592,7 +3783,7 @@ public void doLoadProjectResults() throws Exception { } catch (SQLException sqle) { DBMS.printSqlException(true, sqle); - throw new Exception("Load of 'project_result / project' table failed.\n" + + throw new Exception("Load of '" + targetTable + " / project' table failed.\n" + sqle.getMessage()); } finally { close(projectResults); @@ -3605,6 +3796,21 @@ public void doLoadProjectResults() throws Exception { } } + public void doLoadPublicDesignProjectResults() throws Exception { + doLoadDesignProjectResults(ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "design_project_result", fLastLogTime, null); + } + + public void doLoadPrivateDesignProjectResults() throws Exception { + if (fullLoad) { + for (int i = 0; i < dateFilterBatches.size() - 1; i++) { + log.info("loading projects from "+dateFilterBatches.get(i).toString()); + doLoadDesignProjectResults(WITH_ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "private_design_project_result", dateFilterBatches.get(i), dateFilterBatches.get(i + 1)); + } + } else { + doLoadDesignProjectResults(WITH_ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT, "private_design_project_result", fLastLogTime, null); + } + } + /** * Loads design project result * @@ -3612,7 +3818,7 @@ public void doLoadProjectResults() throws Exception { * * @since 1.2.4 */ - public void doLoadDesignProjectResults() throws Exception { + public void doLoadDesignProjectResults(String eligibilityConstraint, String targetTable, Timestamp startTime, Timestamp endTime) throws Exception { log.info("load design project results"); PreparedStatement firstTimeSelect = null; @@ -3628,38 +3834,46 @@ public void doLoadDesignProjectResults() throws Exception { try { - firstTimeSelect = prepareStatement("SELECT count(*) from design_project_result", TARGET_DB); + firstTimeSelect = prepareStatement("SELECT count(*) from "+targetTable, TARGET_DB); rs = firstTimeSelect.executeQuery(); rs.next(); // no records, it's the first run of loading design project result boolean firstRun = rs.getInt(1) == 0; - final String PROJECTS_SELECT = + String PROJECTS_SELECT = "select distinct p.project_id " + "from project p, " + - "project_info pi, " + + "project_info pi, "; + if (!firstRun && endTime==null) { + PROJECTS_SELECT += "comp_versions cv, " + - "comp_catalog cc, " + + "comp_catalog cc, "; + } + PROJECTS_SELECT += "project_category_lu pcl " + "where " + " p.project_id = pi.project_id " + " and p.project_category_id = pcl.project_category_id " + " and pcl.project_type_id = 3 " + "and p.project_status_id NOT IN (1, 2, 3, 9, 10, 11)" + - "and pi.project_info_type_id = 1 " + + "and pi.project_info_type_id = 1 "+ + eligibilityConstraint; + if (!firstRun && endTime==null) { + PROJECTS_SELECT += "and cv.comp_vers_id= pi.value " + "and cc.component_id = cv.component_id " + - ELIGIBILITY_CONSTRAINTS_SQL_FRAGMENT + - (!firstRun ? - ("and (p.modify_date > ? " + - " OR cv.modify_date > ? " + - " OR pi.modify_date > ? " + - " OR cc.modify_date > ? " + - (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' " + - " OR pi.modify_user <> 'Converter' " + - ")" - : ")")) : ""); + "and (p.modify_date > ? " + + " OR cv.modify_date > ? " + + " OR pi.modify_date > ? " + + " OR cc.modify_date > ? " + + (needLoadMovedProject() ? " OR p.modify_user <> 'Converter' " + + " OR pi.modify_user <> 'Converter' " + + ")" + : ")"); + } else { + PROJECTS_SELECT += "and (p.create_date >= ? and p.create_date < ?)"; + } final String RESULT_SELECT = "SELECT pj.project_id , " + " s.submission_id , " + @@ -3706,7 +3920,7 @@ public void doLoadDesignProjectResults() throws Exception { "LEFT OUTER JOIN prize p ON s.prize_id = p.prize_id "; final String RESULT_INSERT = - "INSERT INTO design_project_result (project_id, user_id, submission_id, upload_id, prize_id, prize_amount, placement, dr_points, is_checkpoint, client_selection, submit_timestamp, review_complete_timestamp, inquire_timestamp, submit_ind, valid_submission_ind) " + + "INSERT INTO " + targetTable + " (project_id, user_id, submission_id, upload_id, prize_id, prize_amount, placement, dr_points, is_checkpoint, client_selection, submit_timestamp, review_complete_timestamp, inquire_timestamp, submit_ind, valid_submission_ind) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; @@ -3715,11 +3929,14 @@ public void doLoadDesignProjectResults() throws Exception { resultInsert = prepareStatement(RESULT_INSERT, TARGET_DB); - if (!firstRun) { - projectSelect.setTimestamp(1, fLastLogTime); - projectSelect.setTimestamp(2, fLastLogTime); - projectSelect.setTimestamp(3, fLastLogTime); - projectSelect.setTimestamp(4, fLastLogTime); + if (!firstRun && endTime == null) { + projectSelect.setTimestamp(1, startTime); + projectSelect.setTimestamp(2, startTime); + projectSelect.setTimestamp(3, startTime); + projectSelect.setTimestamp(4, startTime); + } else { + projectSelect.setTimestamp(1, startTime); + projectSelect.setTimestamp(2, endTime); } projects = projectSelect.executeQuery(); @@ -3736,7 +3953,7 @@ public void doLoadDesignProjectResults() throws Exception { StringBuffer delQuery = new StringBuffer(300); - delQuery.append("delete from design_project_result where project_id in ("); + delQuery.append("delete from " + targetTable + " where project_id in ("); boolean projectsFound = false; @@ -3837,7 +4054,7 @@ public void doLoadDesignProjectResults() throws Exception { } else { // if not submitted if(projectResults.getObject("upload_id") != null || - designProjectResultExists(projectResults.getLong("project_id"), projectResults.getLong("user_id"), 0l)) + designProjectResultExists(projectResults.getLong("project_id"), projectResults.getLong("user_id"), 0l, targetTable)) continue; resultInsert.setLong(++index, projectResults.getLong("project_id")); @@ -3876,7 +4093,7 @@ public void doLoadDesignProjectResults() throws Exception { } catch (SQLException sqle) { DBMS.printSqlException(true, sqle); - throw new Exception("Load of 'design_project_result' table failed.\n" + + throw new Exception("Load of '" + targetTable + "' table failed.\n" + sqle.getMessage()); } finally { close(rs); @@ -3896,13 +4113,13 @@ public void doLoadDesignProjectResults() throws Exception { * @param submissionId Id of the submission * @return true if a design project result already exists, false otherwise */ - private boolean designProjectResultExists(Long projectId, Long userId, Long submissionId) throws SQLException { + private boolean designProjectResultExists(Long projectId, Long userId, Long submissionId, String targetTable) throws SQLException { boolean exists = false; PreparedStatement resultQuery = null; ResultSet result = null; try { - resultQuery = prepareStatement("select count(*) ct from design_project_result where project_id = ? and user_id = ? and submission_id = ?", TARGET_DB); + resultQuery = prepareStatement("select count(*) ct from " + targetTable + " where project_id = ? and user_id = ? and submission_id = ?", TARGET_DB); resultQuery.setLong(1, projectId); resultQuery.setLong(2, userId); resultQuery.setLong(3, submissionId); @@ -7769,7 +7986,6 @@ public void doLoadParticipationStats() throws Exception { * @param seasonId the season id * @param startDate the start date * @param endDate the end date - * @param phaseId the phase id * @param contestId the contest id * @param className the class name * @param factor the factor diff --git a/src/main/com/topcoder/utilities/dwload/fixes/TCLoadDR.java b/src/main/com/topcoder/utilities/dwload/fixes/TCLoadDR.java index 25aad0e45c9..1e9239bf6d3 100644 --- a/src/main/com/topcoder/utilities/dwload/fixes/TCLoadDR.java +++ b/src/main/com/topcoder/utilities/dwload/fixes/TCLoadDR.java @@ -27,7 +27,8 @@ public void performLoad() throws Exception { // Reload project results after 4 may fLastLogTime = new Timestamp(new GregorianCalendar(2007,4,4).getTime().getTime()); - doLoadProjectResults(); + doLoadPublicProjectResults(); + doLoadPrivateProjectResults(); fLastLogTime = new Timestamp(new GregorianCalendar(1980,0,1).getTime().getTime()); doLoadSeason(); diff --git a/src/main/com/topcoder/web/codinginterface/longcontest/view/activeContests.jsp b/src/main/com/topcoder/web/codinginterface/longcontest/view/activeContests.jsp index 6784b925e8c..5c0bda53596 100644 --- a/src/main/com/topcoder/web/codinginterface/longcontest/view/activeContests.jsp +++ b/src/main/com/topcoder/web/codinginterface/longcontest/view/activeContests.jsp @@ -1,5 +1,5 @@ -<%@ page contentType="text/html;charset=utf-8" %> - + <%@ page contentType="text/html;charset=utf-8" %> @@ -31,156 +31,12 @@ - - - - - - - - -<%-- Left Column Begins--%> - -<%-- Left Column Ends --%> - -<%-- Center Column Begins --%> - -<%-- Center Column Ends --%> - -<%-- Right Column Begins --%> - -<%-- Right Column Ends --%> - - - -
- - - - - - - - - - -
- Need help? Learn how to get started

-
-
- - <%-- MM Promo On/Off--%> -
- - -
- - - - - - - - - - - - - - - - - - - - <%boolean even = true;%> - - "> - - - - - - - - - - - <%even = !even;%> - - - - - - -
Active Contests
ContestProblemRegistrantsCompetitorsSubmissionsStart TimeEnd Time
- <% pageContext.setAttribute("sponsorImage", ((LongContest) contest).getSponsorImage());%> -
-
- - - - - - - - - - - -
- ?module=ViewProblemStatement&<%=Constants.COMPONENT_ID%>=&<%=Constants.ROUND_ID%>=" > - - - - - - ?module=ViewReg&<%=Constants.ROUND_ID%>=" - >Register/Submit - - - - - ?module=ViewReg&<%=Constants.ROUND_ID%>=" - >Register - - - ?module=Submit&<%=Constants.COMPONENT_ID%>=&<%=Constants.ROUND_ID%>=&<%=Constants.CONTEST_ID%>=" - >Submit - - - - - - ?module=ViewRegistrants&<%=Constants.ROUND_ID%>=" > - - - - -
-
- There are currently no active contests, but check back soon. -
-
- - - -
- - - -
- - + <% + // New location to be redirected + String site = new String("https://www.topcoder.com/challenges/?filter[tracks][data_science]=true"); + response.setStatus(response.SC_MOVED_PERMANENTLY); + response.setHeader("Location", site); + %> diff --git a/src/main/com/topcoder/web/codinginterface/longcontest/view/instructions.jsp b/src/main/com/topcoder/web/codinginterface/longcontest/view/instructions.jsp index 58850ab3e93..4b09bcf66a5 100644 --- a/src/main/com/topcoder/web/codinginterface/longcontest/view/instructions.jsp +++ b/src/main/com/topcoder/web/codinginterface/longcontest/view/instructions.jsp @@ -11,6 +11,11 @@ +<% + String redirectURL = "https://www.topcoder.com/community/data-science/how-to-compete"; + response.sendRedirect(redirectURL); +%> + @@ -78,4 +83,4 @@ Once the submission phase of a Marathon Match has ended, the final results will - \ No newline at end of file + diff --git a/src/main/com/topcoder/web/common/BaseServlet.java b/src/main/com/topcoder/web/common/BaseServlet.java index 064291e7173..bc2f680f18b 100755 --- a/src/main/com/topcoder/web/common/BaseServlet.java +++ b/src/main/com/topcoder/web/common/BaseServlet.java @@ -5,8 +5,10 @@ import java.io.IOException; import java.io.PrintWriter; +import java.net.URLEncoder; import java.util.List; import java.util.Set; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -15,10 +17,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.hibernate.loader.custom.Return; + import com.topcoder.security.TCSubject; import com.topcoder.shared.security.Authorization; import com.topcoder.shared.security.Resource; import com.topcoder.shared.security.SimpleResource; +import com.topcoder.shared.util.TCResourceBundle; import com.topcoder.shared.security.User; import com.topcoder.shared.util.logging.Logger; import com.topcoder.web.common.error.RequestRateExceededException; @@ -63,6 +68,9 @@ public abstract class BaseServlet extends HttpServlet { public static final String URL_KEY = "url"; public static final String NEXT_PAGE_KEY = "nextpage"; public static final String SESSION_INFO_KEY = "sessionInfo"; + + private static TCResourceBundle bundle = null; + /** *

* Represent the qualified name of this class. @@ -87,7 +95,9 @@ public synchronized void init(ServletConfig config) throws ServletException { PATH = config.getInitParameter("processor_path"); DEFAULT_PROCESSOR = config.getInitParameter("default_processor"); LOGIN_PROCESSOR = config.getInitParameter("login_processor"); + String styleConfig = config.getInitParameter("is_new_style"); + bundle = new TCResourceBundle("TC"); if(styleConfig != null && styleConfig.equalsIgnoreCase("true")) { NEW_STYLE_ENABLED = true; @@ -220,6 +230,7 @@ protected void process(HttpServletRequest request, HttpServletResponse response) authentication = createAuthentication(tcRequest, tcResponse); TCSubject user = getUser(authentication.getActiveUser().getId()); info = createSessionInfo(tcRequest, authentication, user.getPrincipals()); + //we can let browsers/proxies cache pages if the user is anonymous or it's https (they don't really cache https setuff) if (log.isDebugEnabled()) { log.debug("uri: " + request.getRequestURL().toString()); @@ -272,7 +283,6 @@ protected void process(HttpServletRequest request, HttpServletResponse response) //log.debug("path " + PATH); String processorName = getFullProcessorName(cmd); - if (log.isDebugEnabled()) { log.debug("creating request processor for " + processorName); } @@ -483,7 +493,17 @@ protected void handleLogin(HttpServletRequest request, HttpServletResponse respo request.setAttribute(NEXT_PAGE_KEY, info.getRequestString()); request.setAttribute(MODULE, LOGIN_PROCESSOR); - fetchRegularPage(request, response, LOGIN_SERVLET == null ? info.getServletPath() : LOGIN_SERVLET, true); + String loginUrl = bundle.getProperty("login_url", ""); + StringBuffer returnUrl = new StringBuffer(info.getSecureAbsoluteServletPath()); + returnUrl.append(info.getQueryString()); + StringBuffer redirectUrl = new StringBuffer(loginUrl); + redirectUrl.append("?retUrl=").append(URLEncoder.encode(returnUrl.toString(), StandardCharsets.UTF_8.toString())); + + // new login. redirect to auth0 + fetchRegularPage(request, response, redirectUrl.toString(), false); + + // OLD login + //fetchRegularPage(request, response, LOGIN_SERVLET == null ? info.getServletPath() : LOGIN_SERVLET, true); } } diff --git a/src/main/com/topcoder/web/common/render/ProblemRenderer.java b/src/main/com/topcoder/web/common/render/ProblemRenderer.java index 4dc491f4532..7e77354b361 100755 --- a/src/main/com/topcoder/web/common/render/ProblemRenderer.java +++ b/src/main/com/topcoder/web/common/render/ProblemRenderer.java @@ -5,6 +5,7 @@ import com.topcoder.shared.problem.ElementRenderer; import com.topcoder.shared.problem.Problem; import com.topcoder.shared.problem.ProblemComponent; +import java.util.Calendar; import java.awt.*; @@ -18,7 +19,7 @@ public class ProblemRenderer extends BaseRenderer implements ElementRenderer { private Color backgroundColor = null; private Color foregroundColor = null; - private static final String LEGAL = "This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved. "; + private static final String LEGAL = "This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)%d, TopCoder, Inc. All rights reserved. "; public ProblemRenderer() { this.problem = null; @@ -67,7 +68,8 @@ public String toHTML(Language language) throws Exception { } } html.append("

"); - html.append(LEGAL); + int year = Calendar.getInstance().get(Calendar.YEAR); + html.append(String.format(LEGAL, year)); html.append("

"); return html.toString(); diff --git a/src/main/com/topcoder/web/distui/view/leftNavNew.jsp b/src/main/com/topcoder/web/distui/view/leftNavNew.jsp index c802237b998..02aed6032a9 100644 --- a/src/main/com/topcoder/web/distui/view/leftNavNew.jsp +++ b/src/main/com/topcoder/web/distui/view/leftNavNew.jsp @@ -239,6 +239,7 @@ diff --git a/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java b/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java index ca19df025a1..8c809a1d4bf 100755 --- a/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java +++ b/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java @@ -3946,6 +3946,7 @@ private long insertPaymentDetail(Connection c, Payment p, long operatorUserId) t } ps.setNull(26, Types.DECIMAL); ps.setNull(27, Types.VARCHAR); + switch (BasePayment.getReferenceTypeId(p.getHeader().getTypeId())) { case REFERENCE_ALGORITHM_ROUND_ID: setNullableLong(ps, 14, p.getHeader().getAlgorithmRoundId()); @@ -3984,6 +3985,10 @@ private long insertPaymentDetail(Connection c, Payment p, long operatorUserId) t ps.setBoolean(23, p.isCharity()); ps.setDouble(24, p.getTotalAmount() == 0 ? p.getGrossAmount() : p.getTotalAmount()); // default to gross amount if not filled. ps.setInt(25, p.getInstallmentNumber()); + + // Set the jira ID all the time to support v5 + log.info("Jira ID: " + p.getHeader().getJiraIssueName()); + setNullableString(ps, 27, p.getHeader().getJiraIssueName()); if (operatorUserId != 0) { ps.setLong(28, operatorUserId); @@ -6432,6 +6437,10 @@ private Payment createPayment(BasePayment payment) { case REFERENCE_DIGITAL_RUN_TRACK_ID: p.getHeader().setDigitalRunTrackId(((DigitalRunTrackReferencePayment) payment).getTrackId()); break; + default: + // Set the jira ID all the time to support v5 + log.info("*** Jira ID (Create Payment): " + ((NoReferencePayment) payment).getJiraIssueName()); + p.getHeader().setJiraIssueName(((NoReferencePayment) payment).getJiraIssueName()); } diff --git a/src/main/com/topcoder/web/ejb/pacts/payments/PaymentStatusReason.java b/src/main/com/topcoder/web/ejb/pacts/payments/PaymentStatusReason.java index b3d1c120f82..fc66b941da2 100644 --- a/src/main/com/topcoder/web/ejb/pacts/payments/PaymentStatusReason.java +++ b/src/main/com/topcoder/web/ejb/pacts/payments/PaymentStatusReason.java @@ -37,7 +37,8 @@ public enum AvailableStatusReason { EXPIRED_AD_REASON (new PaymentStatusReason(51l, "Expired assignment document")), ACCOUNT_STATUS_REASON (new PaymentStatusReason(52l, "Account status")), ATTACHED_TO_PARENT_REASON (new PaymentStatusReason(100l, "Attached to parent")), - UNDER_AGE_REASON (new PaymentStatusReason(101l, "Member under 18")); + UNDER_AGE_REASON (new PaymentStatusReason(101l, "Member under 18")), + CREATED_BY_V5 (new PaymentStatusReason(500l, "Created by V5")); /** * The PaymentStatusReason attached to the enum element diff --git a/src/main/com/topcoder/web/jsp/foot.jsp b/src/main/com/topcoder/web/jsp/foot.jsp index 764e500cea9..64dfff36703 100755 --- a/src/main/com/topcoder/web/jsp/foot.jsp +++ b/src/main/com/topcoder/web/jsp/foot.jsp @@ -13,6 +13,10 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page import="com.topcoder.shared.util.ApplicationServer, com.topcoder.web.common.BaseServlet, com.topcoder.web.common.SessionInfo" %> +<%@ page import="java.util.Date" %> +<%@ page import="java.text.SimpleDateFormat" %> + +" var="isReskin"/> <% SessionInfo sessionInfo = (SessionInfo)request.getAttribute(BaseServlet.SESSION_INFO_KEY); @@ -24,10 +28,37 @@ } String domainName = ApplicationServer.SERVER_NAME.replace("www.", ""); - + String year = new SimpleDateFormat("yyyy").format(new Date()); %> + + + <%--
--%> <%--
--%> @@ -124,7 +155,7 @@ -
+
@@ -154,14 +185,22 @@ <%-- Analytics --%> + + + - + diff --git a/src/main/com/topcoder/web/jsp/style.jsp b/src/main/com/topcoder/web/jsp/style.jsp index 5c126dea7ab..33a2b7dfd75 100644 --- a/src/main/com/topcoder/web/jsp/style.jsp +++ b/src/main/com/topcoder/web/jsp/style.jsp @@ -14,6 +14,8 @@ <% String key = request.getParameter("key"); Boolean isNewStyle = request.getAttribute("isNewStyle") == null ? false : (Boolean) request.getAttribute("isNewStyle"); + + String reskin = request.getParameter("reskin"); %> <% if (!isNewStyle) { %> <% if (key.equals("tc_old")) { %> @@ -225,3 +227,20 @@ <% } %> + +<% if (reskin != null) { %> + + + + <% if (reskin.equals("paymentHistory")) { %> + + + + + <% } else if (reskin.equals("paymentStatusSummary")) { %> + + + + + <% } %> +<% } %> diff --git a/src/main/com/topcoder/web/jsp/top.jsp b/src/main/com/topcoder/web/jsp/top.jsp index 23d464224ef..7018a8780e0 100755 --- a/src/main/com/topcoder/web/jsp/top.jsp +++ b/src/main/com/topcoder/web/jsp/top.jsp @@ -33,6 +33,8 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib uri="tc-webtags.tld" prefix="tc-webtag" %> +" var="isReskin"/> + <% SessionInfo sessionInfo = (SessionInfo)request.getAttribute(BaseServlet.SESSION_INFO_KEY); String level1 = request.getParameter("level1")==null?"competition":request.getParameter("level1"); @@ -55,6 +57,15 @@ + +
+ +
+
@@ -130,7 +141,7 @@ - diff --git a/src/main/com/topcoder/web/tc/controller/PayPalService.java b/src/main/com/topcoder/web/tc/controller/PayPalService.java index 98d402184fe..e1783e7ab97 100644 --- a/src/main/com/topcoder/web/tc/controller/PayPalService.java +++ b/src/main/com/topcoder/web/tc/controller/PayPalService.java @@ -20,6 +20,9 @@ import java.util.*; import java.io.*; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext;; + /** *

This class provides convenient static methods for calling the PayPal API.

* @@ -216,13 +219,19 @@ private static PayPalConfig getPayPalConfig() throws ConfigManagerException { *

A private helper method that queries the PayPal API with the specified parameters and returns the response.

*/ private static String getNVResponse(String url, String requestBody) throws Exception { - HttpURLConnection connection = null; + HttpsURLConnection connection = null; try { + SSLContext sc = SSLContext.getInstance("TLSv1.2"); + sc.init(null, null, new java.security.SecureRandom()); + PayPalConfig payPalConfig = getPayPalConfig(); - + + log.info("Using TLSv1.2"); + //Create connection - connection = (HttpURLConnection) (new URL(url)).openConnection(); + connection = (HttpsURLConnection) (new URL(url)).openConnection(); + connection.setSSLSocketFactory(sc.getSocketFactory()); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Length", "" + Integer.toString(requestBody.getBytes().length)); diff --git a/src/main/com/topcoder/web/tc/controller/PayoneerService.java b/src/main/com/topcoder/web/tc/controller/PayoneerService.java index 75f7d9bc273..1082b375879 100644 --- a/src/main/com/topcoder/web/tc/controller/PayoneerService.java +++ b/src/main/com/topcoder/web/tc/controller/PayoneerService.java @@ -23,6 +23,9 @@ import java.text.SimpleDateFormat; import java.util.*; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; + /** *

This class provides convenient static methods for calling the Payoneer API.

* @@ -291,9 +294,12 @@ private static PayoneerConfig getPayoneerConfig() throws ConfigManagerException *

This is a private helper method that queries the Payoneer API with the specified parameters and returns the response.

*/ private static Document getXMLResponse(String baseApiUrl, Map parameters) throws Exception { - HttpURLConnection connection = null; + HttpsURLConnection connection = null; try { + SSLContext sc = SSLContext.getInstance("TLSv1.2"); + sc.init(null, null, new java.security.SecureRandom()); + StringBuilder builder = new StringBuilder(); for(String key : parameters.keySet()) { if (builder.length() > 0) { @@ -305,9 +311,11 @@ private static Document getXMLResponse(String baseApiUrl, Map par // Log the request string but hide the password (which is the 'p2' parameter value). log.info("Payoneer request: " + urlParameters.replaceAll(parameters.get("p2"), "XXXXXXXX")); + log.info("Using TLSv1.2"); //Create connection - connection = (HttpURLConnection) (new URL(baseApiUrl)).openConnection(); + connection = (HttpsURLConnection) (new URL(baseApiUrl)).openConnection(); + connection.setSSLSocketFactory(sc.getSocketFactory()); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)); diff --git a/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentHistory.java b/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentHistory.java index 3214f4e5ead..75471ed4d7a 100644 --- a/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentHistory.java +++ b/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentHistory.java @@ -43,10 +43,10 @@ *

* Version 1.1 (Member Payments Automation Assembly 1.0) Change notes: *

    - *
  1. Updated {@link #insertSheetData(Sheet, List)} method to include new Release Date column into + *
  2. Updated {@link #insertSheetData(Sheet, List)} method to include new Release Date column into * generated Excel worksheet.
  3. - *
  4. Updated {@link #businessProcessing()} method to parse new {@link DataAccessConstants#NUMBER_RECORDS} - * parameter and fix the bug with parsing {@link DataAccessConstants#START_RANK} and + *
  5. Updated {@link #businessProcessing()} method to parse new {@link DataAccessConstants#NUMBER_RECORDS} + * parameter and fix the bug with parsing {@link DataAccessConstants#START_RANK} and * {@link DataAccessConstants#END_RANK} parameters.
  6. *
  7. Added {@link #USER_PAYMENT_METHOD} constant.
  8. *
  9. Added {@link #PAYMENT_CONFIRMATION_TEMPLATE} constant.
  10. @@ -67,7 +67,7 @@ public class PaymentHistory extends BaseProcessor implements PactsConstants { /** *

    A String providing the name for request attribute holding the ID of a payment method preferred by * current user.

    - * + * * @since 1.1 */ public static final String USER_PAYMENT_METHOD = "userPaymentMethod"; @@ -81,29 +81,29 @@ public class PaymentHistory extends BaseProcessor implements PactsConstants { public static final String PAYMENT_CONFIRMATION_TEMPLATE = "paymentConfirmationTemplate"; /** - * + * */ public static final String PAYMENT_ID = "paymentId"; - + public static final String CODER = "cr"; private static final int DESCRIPTION_COL = 1; private static final int TYPE_COL = 2; private static final int CREATE_DATE_COL = 3; private static final int NET_PAYMENT_COL = 4; private static final int STATUS_COL = 5; - + /** *

    An int referencing the column with release dates for payments.

    - * + * * @since 1.1 */ private static final int RELEASE_DATE_COL = 6; - + private static final int PAID_DATE_COL = 7; /** *

    Processes the incoming request. Retrieves user payments and binds them to request.

    - * + * * @throws TCWebException if an unexpected error occurs. */ protected void businessProcessing() throws TCWebException { @@ -113,17 +113,17 @@ protected void businessProcessing() throws TCWebException { String sortColStr = StringUtils.checkNull(getRequest().getParameter(DataAccessConstants.SORT_COLUMN)); boolean exportToExcel = "true".equals(getRequest().getParameter(XLS_FORMAT)); String numRecords = StringUtils.checkNull(getRequest().getParameter(DataAccessConstants.NUMBER_RECORDS)); - + boolean sortAscending= "asc".equals(getRequest().getParameter(DataAccessConstants.SORT_DIRECTION)); int sortCol = 3; - + if (sortColStr.trim().length() > 0) { sortCol = Integer.parseInt(sortColStr); } - + // Normalizes optional parameters and sets defaults if ("".equals(numRecords)) { - numRecords = "20"; + numRecords = "10"; } else if (Integer.parseInt(numRecords) > 200) { numRecords = "200"; } @@ -137,54 +137,63 @@ protected void businessProcessing() throws TCWebException { String endRank = String.valueOf(Integer.parseInt(startRank) + Integer.parseInt(numRecords) - 1); setDefault(DataAccessConstants.END_RANK, endRank); - + DataInterfaceBean dib = new DataInterfaceBean(); - + Map criteria = new HashMap(); long userId = getUser().getId(); criteria.put(PactsConstants.USER_ID, String.valueOf(userId)); List payments = dib.findCoderPayments(criteria); - + List removePayments = new ArrayList(); + List removeNonPending = new ArrayList(); + for (BasePayment payment : payments) { if (payment.getPaymentType() == 3 || payment.getPaymentType() == 5) { removePayments.add(payment); } else { - if (!fullList && !exportToExcel) { - if (payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.CANCELLED_PAYMENT_STATUS)) || - payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.EXPIRED_PAYMENT_STATUS)) || - payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.PAID_PAYMENT_STATUS))) { - removePayments.add(payment); - } - } - - // Deleted payments should not be shown either way. - if (payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.DELETED_PAYMENT_STATUS))) { - removePayments.add(payment); + if (!(payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.OWED_PAYMENT_STATUS))) && + !(payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.ENTERED_INTO_PAYMENT_SYSTEM_PAYMENT_STATUS))) && + !(payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.ACCRUING_PAYMENT_STATUS)))) { + removeNonPending.add(payment); } } } - + payments.removeAll(removePayments); - + // sort the result in the first place sortResult(payments, sortCol, sortAscending); - + if ("on".equalsIgnoreCase(com.topcoder.web.tc.Constants.GLOBAL_AD_FLAG)) { removeDuplicateReasons(payments); } + int totalPayment = payments.size(); + + if (!fullList && !exportToExcel) { + if (removeNonPending.size() > 0) { + payments.removeAll(removeNonPending); + } + } + + int pendingPayments = totalPayment - removeNonPending.size(); + + getRequest().setAttribute("NUM_TOTAL", payments.size()); + getRequest().setAttribute("NUM_PER_PAGE", numRecords); + getRequest().setAttribute("NUM_PENDING", pendingPayments); + if (exportToExcel) { produceXLS(payments); } else { // now crop payments = cropResult(payments, Integer.parseInt(startRank), Integer.parseInt(endRank)); - + setDefault(DataAccessConstants.SORT_COLUMN, sortCol + ""); setDefault(DataAccessConstants.SORT_DIRECTION, getRequest().getParameter(DataAccessConstants.SORT_DIRECTION)); - + getRequest().setAttribute(PAYMENTS, payments); getRequest().setAttribute(CODER, userId + ""); getRequest().setAttribute(FULL_LIST, Boolean.valueOf(fullList)); @@ -198,22 +207,22 @@ protected void businessProcessing() throws TCWebException { s.addDefault(RELEASE_DATE_COL, "desc"); s.addDefault(PAID_DATE_COL, "desc"); getRequest().setAttribute(SortInfo.REQUEST_KEY, s); - + // Get user's payment method preferences Long userPaymentMethod = dib.getUserPaymentMethod(userId); getRequest().setAttribute(USER_PAYMENT_METHOD, userPaymentMethod); if (userPaymentMethod != null) { if (userPaymentMethod == PAYPAL_PAYMENT_METHOD_ID) { getRequest() - .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, + .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, Constants.PAYME_CONFIRMATION_MESSAGE_TEMPLATE_PAYPAL); } else if (userPaymentMethod == PAYONEER_PAYMENT_METHOD_ID) { getRequest() - .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, + .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, Constants.PAYME_CONFIRMATION_MESSAGE_TEMPLATE_PAYONEER); } else if (userPaymentMethod == WESTERN_UNION_PAYMENT_METHOD_ID) { getRequest() - .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, + .setAttribute(PAYMENT_CONFIRMATION_TEMPLATE, Constants.PAYME_CONFIRMATION_MESSAGE_TEMPLATE_WESTERN_UNION); } } @@ -289,12 +298,12 @@ private void insertSheetData(Sheet sheet, List payments) { } /** - *

    Gets the items for the specified range within the specified list.

    - * - * @param result a List providing the data. + *

    Gets the items for the specified range within the specified list.

    + * + * @param result a List providing the data. * @param startRank an int providing the index of starting item. * @param endRank an int providing the index of last item. - * @return a List listing the items within the specified range. + * @return a List listing the items within the specified range. */ private List cropResult(List result, int startRank, int endRank) { Boolean croppedDataAfter = Boolean.TRUE; @@ -302,9 +311,9 @@ private List cropResult(List result, int startRank, int endRank) { endRank = result.size(); croppedDataAfter = Boolean.FALSE; } - getRequest().setAttribute("croppedDataAfter", croppedDataAfter); + getRequest().setAttribute("croppedDataAfter", croppedDataAfter); getRequest().setAttribute("croppedDataBefore", new Boolean(startRank > 1)); - + if (result.size() > 0) { if (startRank <= endRank) { @@ -326,7 +335,7 @@ protected void removeDuplicateReasons(List result) { if (result.size() == 0) { return; } - + for (BasePayment bp : result) { if (bp.getCurrentStatus().getReasons().contains(AvailableStatusReason.NO_HARD_COPY_AD_REASON.getStatusReason()) && bp.getCurrentStatus().getReasons().contains(AvailableStatusReason.NO_SIGNED_GLOBAL_AD_REASON.getStatusReason())) { @@ -337,7 +346,7 @@ protected void removeDuplicateReasons(List result) { /** *

    Sorts the specified payments against specified column in specified order.

    - * + * * @param result a list of payments to sort. * @param sortCol a number of column to sort against. * @param sortAscending true if sorting is to be ascending; false if descending. @@ -363,10 +372,10 @@ public int compare(Object arg0, Object arg1) { public int compare(Object arg0, Object arg1) { Date date0 = ((BasePayment) arg0).getCreateDate(); Date date1 = ((BasePayment) arg1).getCreateDate(); - if (date0 == null && date1 == null) return 0; - if (date0 == null && date1 != null) return -1; - if (date0 != null && date1 == null) return 1; - + if (date0 == null && date1 == null) return 0; + if (date0 == null && date1 != null) return -1; + if (date0 != null && date1 == null) return 1; + return date0.compareTo(date1); } }); @@ -377,7 +386,7 @@ public int compare(Object arg0, Object arg1) { if (((BasePayment) arg0).getNetAmount() == ((BasePayment) arg1).getNetAmount()) { return 0; } - + return ((BasePayment) arg0).getNetAmount() < ((BasePayment) arg1).getNetAmount() ? -1 : 1; } }); @@ -403,14 +412,14 @@ public int compare(Object arg0, Object arg1) { }); break; case PAID_DATE_COL: - Collections.sort(result, new Comparator() { + Collections.sort(result, new Comparator() { public int compare(Object arg0, Object arg1) { Date date0 = ((BasePayment) arg0).getPaidDate(); Date date1 = ((BasePayment) arg1).getPaidDate(); - if (date0 == null && date1 == null) return 0; - if (date0 == null && date1 != null) return -1; - if (date0 != null && date1 == null) return 1; - + if (date0 == null && date1 == null) return 0; + if (date0 == null && date1 != null) return -1; + if (date0 != null && date1 == null) return 1; + return date0.compareTo(date1); } }); diff --git a/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentStatusSummary.java b/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentStatusSummary.java index a1b44e09c7f..52c8d0ffad9 100644 --- a/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentStatusSummary.java +++ b/src/main/com/topcoder/web/tc/controller/legacy/pacts/controller/request/member/PaymentStatusSummary.java @@ -1,6 +1,9 @@ package com.topcoder.web.tc.controller.legacy.pacts.controller.request.member; import java.util.Map; +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; import com.topcoder.shared.dataAccess.DataAccess; import com.topcoder.shared.dataAccess.DataAccessInt; @@ -14,6 +17,12 @@ import com.topcoder.web.tc.Constants; import com.topcoder.web.tc.controller.legacy.pacts.common.PactsConstants; +import com.topcoder.web.tc.controller.legacy.pacts.bean.DataInterfaceBean; +import com.topcoder.web.tc.controller.legacy.pacts.common.PactsConstants; +import com.topcoder.web.ejb.pacts.BasePayment; +import com.topcoder.web.ejb.pacts.payments.PaymentStatusFactory; +import com.topcoder.web.ejb.pacts.payments.PaymentStatusFactory.PaymentStatus; + /** * @author VolodymyrK */ @@ -23,7 +32,7 @@ public class PaymentStatusSummary extends BaseProcessor implements PactsConstant public static final String CODER = "cr"; private static final int TYPE_COL = 1; private static final int NET_PAYMENT_COL = 2; - + protected void businessProcessing() throws TCWebException { try { // Prepare request for data retrieval @@ -36,6 +45,8 @@ protected void businessProcessing() throws TCWebException { Map m = dai.getData(r); ResultSetContainer summary = (ResultSetContainer) m.get("payment_status_summary"); + getRequest().setAttribute("NUM_PENDING", this.getPendingPaymentsNumber()); + getRequest().setAttribute(PAYMENT_STATUS_SUMMARY, summary); setNextPage(PactsConstants.PAYMENT_STATUS_SUMMARY_JSP); setIsNextPageInContext(true); @@ -44,4 +55,39 @@ protected void businessProcessing() throws TCWebException { } } -} \ No newline at end of file + private int getPendingPaymentsNumber() throws Exception { + DataInterfaceBean dib = new DataInterfaceBean(); + + Map criteria = new HashMap(); + long userId = getUser().getId(); + criteria.put(PactsConstants.USER_ID, String.valueOf(userId)); + + List payments = dib.findCoderPayments(criteria); + + List removePayments = new ArrayList(); + for (BasePayment payment : payments) { + if (payment.getPaymentType() == 3 || payment.getPaymentType() == 5) { + removePayments.add(payment); + } else { + if (payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.CANCELLED_PAYMENT_STATUS)) || + payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.EXPIRED_PAYMENT_STATUS)) || + payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.PAID_PAYMENT_STATUS)) || + payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.DELETED_PAYMENT_STATUS))) { + removePayments.add(payment); + } + } + } + payments.removeAll(removePayments); + + List paymentPendings = new ArrayList(); + for (BasePayment payment : payments) { + if (payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.OWED_PAYMENT_STATUS)) || + payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.ENTERED_INTO_PAYMENT_SYSTEM_PAYMENT_STATUS)) || + payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.ACCRUING_PAYMENT_STATUS))) { + paymentPendings.add(payment); + } + } + + return paymentPendings.size(); + } +} diff --git a/src/main/com/topcoder/web/tc/view/help/generalFaq.jsp b/src/main/com/topcoder/web/tc/view/help/generalFaq.jsp index 49634436f51..bae8cc86719 100644 --- a/src/main/com/topcoder/web/tc/view/help/generalFaq.jsp +++ b/src/main/com/topcoder/web/tc/view/help/generalFaq.jsp @@ -11,6 +11,11 @@ +<% + String redirectURL = "https://www.topcoder.com/community/data-science/how-to-compete"; + response.sendRedirect(redirectURL); +%> + diff --git a/src/main/com/topcoder/web/tc/view/my_home/index.jsp b/src/main/com/topcoder/web/tc/view/my_home/index.jsp index 57a5648daec..241d5054929 100755 --- a/src/main/com/topcoder/web/tc/view/my_home/index.jsp +++ b/src/main/com/topcoder/web/tc/view/my_home/index.jsp @@ -41,6 +41,11 @@ +<% + String redirectURL = "https://www.topcoder.com/settings/profile"; + response.sendRedirect(redirectURL); +%> + diff --git a/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp b/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp index d718feedd78..e726b572246 100644 --- a/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp +++ b/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp @@ -235,8 +235,9 @@ <% } %> +
    Have a question about - Payment Methods? + Payment Methods?
    diff --git a/src/main/com/topcoder/web/tc/view/pacts/client/PaymentHistory.jsp b/src/main/com/topcoder/web/tc/view/pacts/client/PaymentHistory.jsp index 685957f2881..c0c76a03b50 100755 --- a/src/main/com/topcoder/web/tc/view/pacts/client/PaymentHistory.jsp +++ b/src/main/com/topcoder/web/tc/view/pacts/client/PaymentHistory.jsp @@ -5,7 +5,7 @@ - - Description: This page displays the payments for current user. - - - Version 1.1 (Member Payments Automation assembly) changes: + - Version 1.1 (Member Payments Automation assembly) changes: - added logic for displaying payment's release date. - added controls for data pagination parameters setting. - fixed a bug with passing sr, er parameters when sorting the paginated data. @@ -21,6 +21,7 @@ <%@ page import="com.topcoder.web.ejb.pacts.payments.EnteredIntoPaymentSystemPaymentStatus" %> <%@ page import="com.topcoder.web.ejb.pacts.payments.AccruingPaymentStatus" %> <%@ page import="com.topcoder.web.ejb.pacts.payments.OwedPaymentStatus" %> +<%@ page import="com.topcoder.shared.util.ApplicationServer" %> <%@ page import="java.util.Arrays" %> <%@ page language="java" %> @@ -51,9 +52,17 @@ + +" var="numTotal" /> +" var="numPerPage" /> +" var="numPending" /> + + + + TopCoder - PACTS <% @@ -64,13 +73,14 @@ + @@ -95,7 +161,13 @@ + + + +
    + +
@@ -114,29 +186,115 @@ -
+
+ + + + + + + + + + - + - - - - - - - - + + + + + + + - + - + - "> - ${(payment.currentStatus.id eq OWED or payment.currentStatus.id eq ACCRUING) ? 'highlight' : '' }"> + - - - - + + + - - <% even = !even;%>
Payments
" >Description" >Type" >Create Date" >Net Payment" >Status" >Release Date - +
" >Description" >Type" >Create Date" >Net Payment" >Status" >Release Date + <%----%> " >Date Paid - + <%----%>  
+
${payment.description} @@ -222,51 +398,52 @@ (${payment.installmentNumber}rd (${payment.installmentNumber}th - installment, total amount=${payment.totalAmount}) + installment, total amount=${payment.totalAmount}) - + - ${payment.description} + ${payment.description} - ${payment.description} + ${payment.description} - ${payment.description} + ${payment.description} - ${payment.description} - + ${payment.description} + ${payment.description} - - + + ${payment.paymentTypeDesc}${payment.currentStatus.desc} - + ${payment.paymentTypeDesc}${payment.currentStatus.desc} +
- ${reason.desc}
- + + + + <%-- Paid, Entered into Payment System: checked, disabled--%> - + <%-- Owed, Accruing --%> @@ -279,6 +456,7 @@ <%-- Negative Payment: checked, readonly --%> + <%-- All other cases: un-checked, normal --%> @@ -292,65 +470,259 @@ <%-- All other cases: un-checked, disabled--%> - + + +
- + + + + + + <%-- LIST --%> + +
+ + +
+ + +
+
Type
+
${paymentItem.paymentTypeDesc}
+
+ +
+
Create Date
+
+
+ +
+
Net Payment
+
+
+ +
+
Status
+
+ ${paymentItem.currentStatus.desc} + +
- ${reason.desc} +
+
+
+ +
+
Release Date
+
+
+ + + +
+
+
+ + + + <%-- Paid, Entered into Payment System: checked, disabled--%> + + + + <%-- Owed, Accruing --%> + + + <%-- Payment release date is not reached yet: un-checked, disabled --%> + + + + <%-- Negative Payment: checked, readonly --%> + + + + <%-- All other cases: un-checked, normal --%> + + + + + + <%-- All other cases: un-checked, disabled--%> + + + +
+
+
+
+
+
+ + <%-- FOOTER ACTIONS --%> + +