Example usage for java.util GregorianCalendar getTime

List of usage examples for java.util GregorianCalendar getTime

Introduction

In this page you can find the example usage for java.util GregorianCalendar getTime.

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:org.etudes.jforum.repository.ForumRepository.java

/**
 * check for topic dates/*from w  w w .j  av a2 s . c o  m*/
 * 
 * @param topic      Topic
 * @return         true   if topic is accessible
 *                false   if topic is not accessible
 */
public static boolean isTopicAccessible(Topic topic) throws Exception {
    boolean topicAccessible = false;

    if (topic == null)
        throw new IllegalArgumentException();

    boolean facilitator = JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId())
            || SecurityService.isSuperUser();

    if (facilitator) {
        return true;
    }

    GregorianCalendar gc = new GregorianCalendar();
    Date nowDate = gc.getTime();

    // topic access dates and special access check 
    if (!facilitator) {
        UserSession userSession = SessionFacade.getUserSession();
        if (topic.getStartDate() != null) {
            // consider topics special access
            List<SpecialAccess> topicsSpecialAccessList = DataAccessDriver.getInstance().newSpecialAccessDAO()
                    .selectByTopic(topic.getForumId(), topic.getId());
            Date curDate = new Date(System.currentTimeMillis());
            boolean specialAccessUser = false;
            boolean specialAccessUserAccess = false;

            topic.setSpecialAccessList(topicsSpecialAccessList);

            if (topicsSpecialAccessList.size() > 0) {
                for (SpecialAccess sa : topicsSpecialAccessList) {
                    if (sa.getUserIds().contains(userSession.getUserId())) {
                        specialAccessUser = true;

                        if (!sa.isOverrideStartDate()) {
                            sa.setStartDate(topic.getStartDate());
                        }
                        if (!sa.isOverrideEndDate()) {
                            sa.setEndDate(topic.getEndDate());
                        }
                        if (!sa.isOverrideLockEndDate()) {
                            sa.setLockOnEndDate(topic.isLockTopic());
                        }
                        if (!sa.isOverrideAllowUntilDate()) {
                            sa.setAllowUntilDate(topic.getAllowUntilDate());
                        }
                        if (sa.getStartDate() == null || curDate.after(sa.getStartDate())) {
                            specialAccessUserAccess = true;
                        }
                        break;
                    }
                }
            }

            if (specialAccessUser) {
                if (specialAccessUserAccess) {
                    topicAccessible = true;
                }
            } else {
                if (topic.getStartDate().before(nowDate)) {
                    topicAccessible = true;
                }
            }
        } else if ((topic.getStartDate() == null)
                && (topic.getEndDate() != null || topic.getAllowUntilDate() != null)) {
            // consider topics special access
            List<SpecialAccess> topicsSpecialAccessList = DataAccessDriver.getInstance().newSpecialAccessDAO()
                    .selectByTopic(topic.getForumId(), topic.getId());
            Date curDate = new Date(System.currentTimeMillis());
            boolean specialAccessUser = false;
            boolean specialAccessUserAccess = false;

            topic.setSpecialAccessList(topicsSpecialAccessList);

            if (topicsSpecialAccessList.size() > 0) {
                for (SpecialAccess sa : topicsSpecialAccessList) {
                    if (sa.getUserIds().contains(userSession.getUserId())) {
                        specialAccessUser = true;

                        if (!sa.isOverrideStartDate()) {
                            sa.setStartDate(topic.getStartDate());
                        }
                        if (!sa.isOverrideEndDate()) {
                            sa.setEndDate(topic.getEndDate());
                        }
                        if (!sa.isOverrideLockEndDate()) {
                            sa.setLockOnEndDate(topic.isLockTopic());
                        }
                        if (!sa.isOverrideAllowUntilDate()) {
                            sa.setAllowUntilDate(topic.getAllowUntilDate());
                        }
                        if (sa.getStartDate() == null || curDate.after(sa.getStartDate())) {
                            specialAccessUserAccess = true;
                        }
                        break;
                    }
                }
            }

            if (specialAccessUser) {
                if (specialAccessUserAccess) {
                    topicAccessible = true;
                }
            } else {
                topicAccessible = true;
            }
        } else {
            topicAccessible = true;
        }
    }

    return topicAccessible;
}

From source file:org.etudes.jforum.repository.ForumRepository.java

/**
 * check if user is special access user/*www .  ja va 2 s. c  o m*/
 * 
 * @param forum         Forum
 * @return            true   if user is special access user
 *                   false   if user is not special access user
 * @throws Exception
 */
public static boolean isSpecialAccessUser(Forum forum) throws Exception {

    if (forum == null)
        throw new IllegalArgumentException();

    if (JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId())
            || SecurityService.isSuperUser()) {
        return false;
    }

    if (JForumUserUtil.isJForumParticipant(UserDirectoryService.getCurrentUser().getId())) {
        try {
            Site site = SiteService.getSite(ToolManager.getCurrentPlacement().getContext());

            Collection sakaiSiteGroups = site
                    .getGroupsWithMember(UserDirectoryService.getCurrentUser().getId());

            GregorianCalendar gc = new GregorianCalendar();
            Date nowDate = gc.getTime();

            UserSession currentUser = SessionFacade.getUserSession();

            if (forum.getAccessType() == Forum.ACCESS_GROUPS) {
                for (Iterator usrGrpIter = sakaiSiteGroups.iterator(); usrGrpIter.hasNext();) {
                    org.sakaiproject.site.api.Group grp = (org.sakaiproject.site.api.Group) usrGrpIter.next();
                    if (forum.getGroups() != null) {
                        if (forum.getGroups().contains(grp.getId())) {
                            // check for forum group special access
                            List<SpecialAccess> specialAccessList = forum.getSpecialAccessList();

                            boolean specialAccessUser = false, specialAccessUserAccess = false;
                            for (SpecialAccess sa : specialAccessList) {
                                if ((sa.getUserIds().contains(currentUser.getUserId()))) {
                                    specialAccessUser = true;

                                    if (!sa.isOverrideStartDate()) {
                                        sa.setStartDate(forum.getStartDate());
                                    }
                                    if (!sa.isOverrideEndDate()) {
                                        sa.setEndDate(forum.getEndDate());
                                    }
                                    if (!sa.isOverrideLockEndDate()) {
                                        sa.setLockOnEndDate(forum.isLockForum());
                                    }

                                    if (sa.getStartDate() == null) {
                                        specialAccessUserAccess = true;
                                    } else if (nowDate.getTime() > sa.getStartDate().getTime()) {
                                        specialAccessUserAccess = true;
                                    }

                                    break;
                                }

                            }

                            if (specialAccessUser) {
                                return specialAccessUserAccess;
                            }

                            return false;
                        }
                    } else {
                        return false;
                    }
                }
            } else if (forum.getAccessType() == Forum.ACCESS_DENY) {
                return false;
            } else {

                // check forum special access
                List<SpecialAccess> forumSpecialAccessList = forum.getSpecialAccessList();
                boolean specialAccessUser = false, specialAccessUserAccess = false;

                if (forumSpecialAccessList != null) {
                    for (SpecialAccess specialAccess : forumSpecialAccessList) {
                        if (specialAccess.getUserIds().contains(currentUser.getUserId())) {
                            specialAccessUser = true;

                            if (!specialAccess.isOverrideStartDate()) {
                                specialAccess.setStartDate(forum.getStartDate());
                            }
                            if (!specialAccess.isOverrideEndDate()) {
                                specialAccess.setEndDate(forum.getEndDate());
                            }
                            if (!specialAccess.isOverrideLockEndDate()) {
                                specialAccess.setLockOnEndDate(forum.isLockForum());
                            }

                            if ((specialAccess.getStartDate() != null)
                                    && (nowDate.getTime() < specialAccess.getStartDate().getTime())) {
                                specialAccessUserAccess = false;
                            } else {
                                specialAccessUserAccess = true;
                            }
                            break;
                        }
                    }
                }

                if (specialAccessUser) {
                    return specialAccessUserAccess;
                } else {
                    return false;
                }
            }
        } catch (IdUnusedException e) {
            return false;
        }
    }
    return false;

}

From source file:it.txt.access.capability.revocation.wizard.panel.PanelRevocationData.java

private void button_revoked_auCap_token_loadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_revoked_auCap_token_loadActionPerformed
    int returnValue = auCapTokenChooser.showOpenDialog(myContainer);
    if (returnValue == JFileChooser.APPROVE_OPTION) {
        File assertionFile = auCapTokenChooser.getSelectedFile();
        AccessRightsCapabilityType capability = AuCapTokenLoader.load(assertionFile, this);
        if (capability != null) {
            textbox_revoked_aucap_id.setText(capability.getAccessRightsCapabilityID());
            GregorianCalendar issueDateTime = capability.getIssueInstant().toGregorianCalendar();
            textbox_revoked_aucap_issue_datetime.setValue(issueDateTime.getTime());
            textbox_revoked_aucap_issue_time.setValue(issueDateTime.getTime());
            textbox_revoked_aucap_issuer.setText(capability.getIssuer().getValue());
            textbox_revoked_aucap_version.setText(capability.getVersion());
            revoked_auCap_token_path.setText(assertionFile.getAbsolutePath());
        }/*from w w w  . j  av  a2 s  . co  m*/
    }
}

From source file:org.apache.torque.generated.peer.DefaultValuesFromJavaTest.java

/**
 * Checks that if CURRENT_DATE is used as default value
 * then an object is constructed with current java time.
 *
 * @throws Exception if an error occurs.
 *///from  w w w  .j  ava  2s. c  o  m
public void testCurrentDateAsJavaDefault() throws Exception {
    if (defaultAdapter instanceof MssqlAdapter || defaultAdapter instanceof MysqlAdapter) {
        log.error("testCurrentDateAsJavaDefault(): "
                + "MSSQL and Mysql do not support the CURRENT_DATE function");
        return;
    }
    GregorianCalendar currentCalendarBefore = new GregorianCalendar();
    currentCalendarBefore.set(GregorianCalendar.HOUR_OF_DAY, 0);
    currentCalendarBefore.set(GregorianCalendar.MINUTE, 0);
    currentCalendarBefore.set(GregorianCalendar.SECOND, 0);
    currentCalendarBefore.set(GregorianCalendar.MILLISECOND, 0);
    JavaDefaultValues javaDefaultValues = new JavaDefaultValues();
    GregorianCalendar currentCalendarAfter = new GregorianCalendar();
    currentCalendarAfter.set(GregorianCalendar.HOUR_OF_DAY, 0);
    currentCalendarAfter.set(GregorianCalendar.MINUTE, 0);
    currentCalendarAfter.set(GregorianCalendar.SECOND, 0);
    currentCalendarAfter.set(GregorianCalendar.MILLISECOND, 0);

    assertFalse(
            "currentDate " + javaDefaultValues.getCurrentDateValue() + " should be >= currentDateBefore "
                    + currentCalendarBefore.getTime(),
            javaDefaultValues.getCurrentDateValue().before(currentCalendarBefore.getTime()));
    assertFalse(
            "currentDate " + javaDefaultValues.getCurrentDateValue() + " should be <= currentDateAfter "
                    + currentCalendarAfter.getTime(),
            javaDefaultValues.getCurrentDateValue().after(currentCalendarAfter.getTime()));
}

From source file:com.collabnet.ccf.pi.sfee.v44.SFEEWriter.java

/**
 * Creates the artifact represented by the GenericArtifact object on the
 * target TF system//  w  ww . java 2s.  c o m
 * 
 * @param ga
 *            - the GenericArtifact object
 * @param tracker
 *            - The target TF tracker ID
 * @param connection
 *            - The Connection object for the target TF system
 * @return - the newly created artifact's ArtifactSoapDO object
 */
private ArtifactSoapDO createArtifact(GenericArtifact ga, String tracker, Connection connection) {
    ArrayList<String> flexFieldNames = new ArrayList<String>();
    ArrayList<String> flexFieldTypes = new ArrayList<String>();
    ArrayList<Object> flexFieldValues = new ArrayList<Object>();

    List<GenericArtifactField> gaFields = ga
            .getAllGenericArtifactFieldsWithSameFieldType(GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD);
    String targetSystemTimezone = ga.getTargetSystemTimezone();
    if (gaFields != null) {
        for (GenericArtifactField gaField : gaFields) {
            String fieldName = gaField.getFieldName();
            String trackerFieldValueType = ArtifactMetaData
                    .getSFEEFieldValueTypeForGAFieldType(gaField.getFieldValueType());
            flexFieldNames.add(fieldName);
            flexFieldTypes.add(trackerFieldValueType);
            Object value = null;
            FieldValueTypeValue fieldType = gaField.getFieldValueType();
            if (trackerFieldValueType.equals(TrackerFieldSoapDO.FIELD_VALUE_TYPE_DATE)) {
                if (fieldType == FieldValueTypeValue.DATE) {
                    GregorianCalendar gc = (GregorianCalendar) gaField.getFieldValue();
                    if (gc != null) {
                        Date dateValue = gc.getTime();
                        if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                            value = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
                        } else {
                            value = dateValue;
                        }
                    }
                } else if (fieldType == FieldValueTypeValue.DATETIME) {
                    value = gaField.getFieldValue();
                }
            } else {
                value = gaField.getFieldValue();
            }
            flexFieldValues.add(value);
        }
    }

    String folderId = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.folderId.getFieldName(), ga);
    String description = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.description.getFieldName(), ga);
    String category = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.category.getFieldName(), ga);
    String group = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.group.getFieldName(), ga);
    String status = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.status.getFieldName(), ga);
    String statusClass = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.statusClass.getFieldName(), ga);
    String customer = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.customer.getFieldName(), ga);
    int priority = GenericArtifactHelper
            .getIntMandatoryGAField(ArtifactMetaData.SFEEFields.priority.getFieldName(), ga);
    int estimatedHours = GenericArtifactHelper
            .getIntMandatoryGAField(ArtifactMetaData.SFEEFields.estimatedHours.getFieldName(), ga);
    int actualHours = GenericArtifactHelper
            .getIntMandatoryGAField(ArtifactMetaData.SFEEFields.actualHours.getFieldName(), ga);
    Date closeDate = GenericArtifactHelper
            .getDateMandatoryGAField(ArtifactMetaData.SFEEFields.closeDate.getFieldName(), ga);
    String assignedTo = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.assignedTo.getFieldName(), ga);
    String reportedReleaseId = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.reportedReleaseId.getFieldName(), ga);
    String resolvedReleaseId = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.resolvedReleaseId.getFieldName(), ga);
    String title = GenericArtifactHelper
            .getStringMandatoryGAField(ArtifactMetaData.SFEEFields.title.getFieldName(), ga);
    String[] comments = this.getComments(ga);
    ArtifactSoapDO result = null;
    try {
        if (this.translateTechnicalReleaseIds) {
            reportedReleaseId = trackerHandler.convertReleaseId(connection.getSessionId(), reportedReleaseId,
                    folderId);
            resolvedReleaseId = trackerHandler.convertReleaseId(connection.getSessionId(), resolvedReleaseId,
                    folderId);
        }
        result = trackerHandler.createArtifact(connection.getSessionId(), folderId, description, category,
                group, status, statusClass, customer, priority, estimatedHours, actualHours, closeDate,
                assignedTo, reportedReleaseId, resolvedReleaseId, flexFieldNames, flexFieldValues,
                flexFieldTypes, title, comments);
        log.info("New artifact " + result.getId() + " is created with the change from "
                + ga.getSourceArtifactId());
    } catch (RemoteException e) {
        String cause = "While trying to create an artifact within TF, an error occured";
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    return result;
}

From source file:com.collabnet.ccf.pi.sfee.v44.SFEEWriter.java

/**
 * Creates the artifact represented by the GenericArtifact object on the
 * target TF system//from  www  .  j  a v  a  2  s.  c o  m
 * 
 * @param ga
 * @param tracker
 * @param forceOverride
 * @param connection
 * @return - returns the updated artifact's ArtifactSoapDO object
 */
private ArtifactSoapDO updateArtifact(GenericArtifact ga, String tracker, Connection connection) {
    String id = ga.getTargetArtifactId();
    ArrayList<String> flexFieldNames = new ArrayList<String>();
    ArrayList<String> flexFieldTypes = new ArrayList<String>();
    ArrayList<Object> flexFieldValues = new ArrayList<Object>();
    Set<String> overriddenFlexFields = new HashSet<String>();
    List<GenericArtifactField> gaFields = ga
            .getAllGenericArtifactFieldsWithSameFieldType(GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD);
    String targetSystemTimezone = ga.getTargetSystemTimezone();
    if (gaFields != null) {
        for (GenericArtifactField gaField : gaFields) {
            String fieldName = gaField.getFieldName();
            if (gaField.getFieldValueHasChanged()) {
                overriddenFlexFields.add(fieldName);
            } else {
                continue;
            }
            String trackerFieldValueType = ArtifactMetaData
                    .getSFEEFieldValueTypeForGAFieldType(gaField.getFieldValueType());
            flexFieldNames.add(fieldName);
            flexFieldTypes.add(trackerFieldValueType);
            Object value = null;
            FieldValueTypeValue fieldType = gaField.getFieldValueType();
            if (trackerFieldValueType.equals(TrackerFieldSoapDO.FIELD_VALUE_TYPE_DATE)) {
                if (fieldType == FieldValueTypeValue.DATE) {
                    GregorianCalendar gc = (GregorianCalendar) gaField.getFieldValue();
                    if (gc != null) {
                        Date dateValue = gc.getTime();
                        if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                            value = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
                        } else {
                            value = dateValue;
                        }
                    }
                } else if (fieldType == FieldValueTypeValue.DATETIME) {
                    value = gaField.getFieldValue();
                }
            } else {
                value = gaField.getFieldValue();
            }
            flexFieldValues.add(value);
        }
    }

    GenericArtifactField folderId = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.folderId.getFieldName(), ga);
    GenericArtifactField description = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.description.getFieldName(), ga);
    GenericArtifactField category = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.category.getFieldName(), ga);
    GenericArtifactField group = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.group.getFieldName(), ga);
    GenericArtifactField status = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.status.getFieldName(), ga);
    GenericArtifactField statusClass = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.statusClass.getFieldName(), ga);
    GenericArtifactField customer = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.customer.getFieldName(), ga);
    GenericArtifactField priority = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.priority.getFieldName(), ga);
    GenericArtifactField estimatedHours = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.estimatedHours.getFieldName(), ga);
    GenericArtifactField actualHours = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.actualHours.getFieldName(), ga);
    GenericArtifactField closeDate = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.closeDate.getFieldName(), ga);
    GenericArtifactField assignedTo = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.assignedTo.getFieldName(), ga);
    GenericArtifactField reportedReleaseId = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.reportedReleaseId.getFieldName(), ga);
    GenericArtifactField resolvedReleaseId = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.resolvedReleaseId.getFieldName(), ga);
    GenericArtifactField title = GenericArtifactHelper
            .getMandatoryGAField(ArtifactMetaData.SFEEFields.title.getFieldName(), ga);

    String[] comments = this.getComments(ga);
    ArtifactSoapDO result = null;
    try {
        result = trackerHandler.updateArtifact(ga, connection.getSessionId(), folderId, description, category,
                group, status, statusClass, customer, priority, estimatedHours, actualHours, closeDate,
                assignedTo, reportedReleaseId, resolvedReleaseId, flexFieldNames, flexFieldValues,
                flexFieldTypes, overriddenFlexFields, title, id, comments, translateTechnicalReleaseIds);
        if (result != null) {
            log.info("Artifact " + id + " is updated successfully");
        }
    } catch (RemoteException e) {
        String cause = "While trying to update an artifact within TF, an error occured";
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    return result;
}

From source file:org.activiti.kickstart.service.alfresco.AlfrescoKickstartServiceImpl.java

public List<KickstartWorkflowInfo> findWorkflowInformation(boolean includeCounts) {

    if (includeCounts) {
        // Not yet implemented, cause it would be an 1+n call ...
        throw new UnsupportedOperationException();
    }//from w w w.  j a  v a2s  .  c  o m

    // Fetch all BPMN 2.0 xml processes from the definitions folder
    Session cmisSession = getCmisSession();
    Folder workflowDefinitionFolder = (Folder) cmisSession.getObjectByPath(WORKFLOW_DEFINITION_FOLDER);
    String query = "select t.cm:description, d." + PropertyIds.NAME + ", d." + PropertyIds.CREATION_DATE
            + " from cmis:document as d join cm:titled as t on d.cmis:objectId = t.cmis:objectId where in_folder(d, '"
            + workflowDefinitionFolder.getId() + "') and d.cmis:name LIKE '%.bpmn20.xml' order by d.cmis:name";
    LOGGER.info("Executing CMIS query '" + query + "'");
    ItemIterable<QueryResult> results = cmisSession.query(query, false);

    // Transmorph them into the correct KickstartWorkflowInfo object
    ArrayList<KickstartWorkflowInfo> workflowInfos = new ArrayList<KickstartWorkflowInfo>();
    for (QueryResult result : results) {
        // We're using only a fraction of the KickstartWorkflowInfo objects
        KickstartWorkflowInfo kickstartWorkflowInfo = new KickstartWorkflowInfo();
        kickstartWorkflowInfo.setName((String) result.getPropertyValueById("cm:description"));
        kickstartWorkflowInfo
                .setId(processNameToBaseName((String) result.getPropertyValueById(PropertyIds.NAME)));
        GregorianCalendar createDate = result.getPropertyValueById(PropertyIds.CREATION_DATE);
        kickstartWorkflowInfo.setCreateTime(createDate.getTime());
        workflowInfos.add(kickstartWorkflowInfo);
    }

    return workflowInfos;
}

From source file:com.sapienter.jbilling.common.GatewayBL.java

private CreditCardDTO parseCreditCard() throws ValidatorException {
    CreditCardDTO creditCard = new CreditCardDTO();
    creditCard.setNumber(getStringPar("s_number"));
    creditCard.setName(getStringPar("s_name"));
    validate("CreditCard", creditCard);

    // get the expiry date
    Integer month = getIntPar("s_expiry_month", true);
    Integer year = getIntPar("s_expiry_year", true);
    vRange("s_expiry_month", 1, 12);
    vRange("s_expiry_year", 4, 99);
    if (code != RES_CODE_OK) {
        return null;
    }/*from   w  w w .  j  a v  a  2 s . co  m*/
    GregorianCalendar cal = new GregorianCalendar();
    cal.clear();
    cal.set(year.intValue() + 2000, month.intValue() - 1, 1);
    creditCard.setCcExpiry(cal.getTime());

    return creditCard;
}

From source file:org.curriki.xwiki.plugin.lucene.ResourcesSearchCursor.java

public String readRequest(Map<String, String[]> paramsS) throws Exception {
    try {//from w  ww . j a  va2  s  . co  m
        Map<String, String> params = new HashMap<String, String>(paramsS.size());
        for (Map.Entry<String, String[]> entry : paramsS.entrySet()) {
            String[] val = entry.getValue();
            if (val.length == 0)
                continue;
            String first = val[0];
            if (first != null && first.length() > 0)
                params.put(entry.getKey(), first);
        }
        // add default values
        for (Map.Entry<String, String> entry : requestDefaults.entrySet()) {
            if (!params.containsKey(entry.getKey()))
                params.put(entry.getKey(), entry.getValue());
        }

        // compute start and end
        if (params.get("start") != null) {
            start = Integer.parseInt(params.get("start"));
        }
        if (params.get("limit") != null) {
            limit = Integer.parseInt(params.get("limit"));
        }

        // compute sort-field
        if ("title".equals(params.get("sort"))) {
            sortField1 = "title.untokenized";
            sortField2 = "CurrikiCode.AssetClass.instructional_component.key.untokenized";
        } else if ("ictText".equals(params.get("sort"))) {
            sortField1 = "CurrikiCode.AssetClass.instructional_component.key.untokenized";
            sortField2 = "title.untokenized";
        } else if ("contributor".equals(params.get("sort"))) {
            sortField1 = "creator.untokenized";
            sortField2 = "title.untokenized";
        } else if ("rating".equals(params.get("sort"))) {
            sortField1 = "-" + IndexFields.I2GEO_REVIEW_OVERALL_RANKING;
            sortField2 = "title.untokenized";
        } else if ("updated".equals(params.get("sort"))) {
            sortField1 = "-date";
            sortField2 = "title.untokenized";
        } else {
            sortField1 = "relevance";
            sortField2 = null;
        }

        // descending asccending
        if (!"relevance".equals(sortField1) && "DESC".equals(params.get("dir"))) {
            if (sortField1.startsWith("-"))
                sortField1 = sortField1.substring(1);
            else
                sortField1 = "-" + sortField1;
        }
        sortFields = (sortField1 + "," + sortField2).split(",");

        // buid query
        queries = new ArrayList<String>();
        if (luceneQuery != null) {
            this.precomputedLuceneQuery = (Query) luceneQuery;
        } else if (params.get("terms") != null) {
            queries.add(params.get("terms"));
        }

        if (params.get("subject") != null) {
            if (!params.get("subject").equals("UNCATEGORIZED")) {
                queries.add("CurrikiCode.AssetClass.fw_items:" + params.get("subject"));
            } else {
                List<String> docs = (List<String>) xwiki.searchDocuments(
                        "where doc.web='FW_masterFramework' and doc.parent='FW_masterFramework.WebHome' order by doc.title");
                for (String docName : docs) {
                    queries.add("-CurrikiCode.AssetClass.fw_items:" + docName);
                }
            }
        }

        if (params.get("filetype") != null) {
            queries.add("CurrikiCode.AssetClass.category:" + params.get("fileType"));
        }

        if (params.get("language") != null) {
            queries.add("CurrikiCode.AssetClass.language:" + params.get("language"));
            languages = params.get("language");
        }
        if (params.get("level") != null) {
            queries.add("CurrikiCode.AssetClass.educational_level2.key:" + params.get("level"));
        }
        if (params.get("ict") != null) {
            queries.add("CurrikiCode.AssetClass.instructional_component2.key:" + params.get("ict"));
        }

        if (params.get("other") != null) {
            queries.add(params.get("other"));
        }
        if (params.get("review") != null) {
            /* TODO: queries for higher quality
            if("high".equals(params.get("review"))) {
                    
            } else if ("highest".equals(params.get("review"))) {
            queries.add()
            }*/
            /* if("partners".equals(params.get("review"))) {
            queries.add("CRS.CurrikiReviewStatusClass.status:200");
            } else if("highest_rated".equals(params.get("review"))) {
            queries.add("CRS.CurrikiReviewStatusClass.status:(800 OR 700)");
            }*/
        }

        if (params.get("special") != null) {
            if ("mine".equals(params.get("special"))) {
                queries.add("creator:" + context.getUser());
            } else if ("collections".equals(params.get("special"))) {
                queries.add("XWiki.CompositeAssetClass.type:collection");
            } else if ("reviewed".equals(params.get("collections"))) {
                queries.add(
                        "CRS.CurrikiReviewStatusClass.status:(200 OR 300 OR 400 OR 500 OR 600 OR 700 OR 800)");
            } else if ("updated".equals(params.get("special"))) {
                queries.add("XWiki.CompositeAssetClass.type:collection");
                GregorianCalendar cal = new GregorianCalendar();
                cal.roll(GregorianCalendar.YEAR, false); // one year earlier
                queries.add(
                        "date:[" + new SimpleDateFormat("yyyyMMdd").format(cal.getTime()) + " TO 29991231]");

            } else if ("groups".equals(params.get("speical"))) {
                queries.add("web:Group_Coll_*");
            }

            if (params.containsKey("extraQuery")) {
                extraQuery = params.get("extraQuery");
            }
        }

        // assemble a string of queries
        return "ok";
    } catch (Exception e) {
        e.printStackTrace();
        messages.add("Trouble at reading requests: " + e.toString());
        return "error";
    }
}

From source file:org.squale.squalecommon.daolayer.component.AuditDAOImpl.java

/**
 * Dcale l'audit de rotation des partitions  la prochaine date prvue Le dlai prvu entre 2 rotations est de 12
 * semaines/*from ww  w  . ja  v a2  s  .c om*/
 * 
 * @param pSession la session
 * @throws JrafDaoException en cas d'chec
 */
public void reportRotationAudit(ISession pSession) throws JrafDaoException {
    // Rcupre l'audit de rotation
    Collection result = findRotationAudit(pSession);
    if (result != null && result.size() != 0) {
        // il ne doit y avoir qu'un seul lment
        Iterator it = result.iterator();
        AuditBO rotationAudit = (AuditBO) it.next();
        Date currentDate = rotationAudit.getDate();
        // ajout le dlai prvu
        GregorianCalendar currentCal = new GregorianCalendar();
        currentCal.setTime(currentDate);
        currentCal.add(Calendar.WEEK_OF_YEAR, ROTATION_DELAY_IN_WEEKS);
        rotationAudit.setDate(currentCal.getTime());
        // et mise  jour en base
        save(pSession, rotationAudit);
    }
}