Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.DateTimeFactory


    protected long determineInitialDelay( String initialTimeExpression ) {
        Matcher matcher = RepositoryConfiguration.INITIAL_TIME_PATTERN.matcher(initialTimeExpression);
        if (matcher.matches()) {
            int hours = Integer.decode(matcher.group(1));
            int mins = Integer.decode(matcher.group(2));
            DateTimeFactory factory = runningState().context().getValueFactories().getDateFactory();
            DateTime now = factory.create();
            DateTime initialTime = factory.create(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), hours, mins, 0, 0);
            long delay = initialTime.getMilliseconds() - System.currentTimeMillis();
            if (delay <= 0L) {
                initialTime = initialTime.plusDays(1);
                delay = initialTime.getMilliseconds() - System.currentTimeMillis();
            }
View Full Code Here


                    case PropertyType.LONG:
                        return this.getLong() == that.getLong();
                    case PropertyType.DECIMAL:
                        return getDecimal().equals(that.getDecimal());
                    case PropertyType.DATE:
                        DateTimeFactory dateFactory = factories().getDateFactory();
                        DateTime thisDateValue = dateFactory.create(this.value);
                        DateTime thatDateValue = dateFactory.create(that.value);
                        return thisDateValue.equals(thatDateValue);
                    case PropertyType.PATH:
                        PathFactory pathFactory = factories().getPathFactory();
                        Path thisPathValue = pathFactory.create(this.value);
                        Path thatPathValue = pathFactory.create(that.value);
View Full Code Here

            } else if (Long[].class.equals(type)) {
                return type.cast(property.getValuesAsArray(context().getValueFactories().getLongFactory()));
            } else if (Boolean[].class.equals(type)) {
               return type.cast(property.getValuesAsArray(context().getValueFactories().getBooleanFactory()));
            } else if (Date[].class.equals(type)) {
                final DateTimeFactory dateFactory = context().getValueFactories().getDateFactory();
                Date[] result = property.getValuesAsArray(new Property.ValueTypeTransformer<Date>() {
                    @Override
                    public Date transform( Object value ) {
                        return dateFactory.create(value).toDate();
                    }
                }, Date.class);
                return type.cast(result);
            } else if (Calendar[].class.equals(type)) {
                final DateTimeFactory dateFactory = context().getValueFactories().getDateFactory();
                Calendar[] result = property.getValuesAsArray(new Property.ValueTypeTransformer<Calendar>() {
                    @Override
                    public Calendar transform( Object value ) {
                        return dateFactory.create(value).toCalendar();
                    }
                }, Calendar.class);
                return type.cast(result);
            } else if (DateTime[].class.equals(type)) {
                return type.cast(property.getValuesAsArray(context().getValueFactories().getDateFactory()));
View Full Code Here

     */
    protected void cleanupLocks( Set<String> activeSessionIds ) {
        try {
            ExecutionContext context = repository.context();

            DateTimeFactory dates = context.getValueFactories().getDateFactory();
            DateTime now = dates.create();
            DateTime newExpiration = dates.create(now, RepositoryConfiguration.LOCK_EXTENSION_INTERVAL_IN_MILLIS);

            PropertyFactory propertyFactory = context.getPropertyFactory();
            SessionCache systemSession = repository.createSystemSession(context, false);
            SystemContent systemContent = new SystemContent(systemSession);

View Full Code Here

        assert node != null;

        final ExecutionContext context = session.context();
        final String owner = ownerInfo != null ? ownerInfo : session.getUserID();

        final DateTimeFactory dateFactory = context.getValueFactories().getDateFactory();
        long expirationTimeInMillis = RepositoryConfiguration.LOCK_EXPIRY_AGE_IN_MILLIS;
        if (timeoutHint > 0 && timeoutHint < Long.MAX_VALUE) {
            expirationTimeInMillis = TimeUnit.MILLISECONDS.convert(timeoutHint, TimeUnit.SECONDS);
        }
        DateTime expirationDate = dateFactory.create().plus(expirationTimeInMillis, TimeUnit.MILLISECONDS);

        // Create a new lock ...
        SessionCache systemSession = repository.createSystemSession(context, false);
        SystemContent system = new SystemContent(systemSession);
        NodeKey nodeKey = node.getKey();
View Full Code Here

         *         version history that was checked in before {@code checkinTime}; never null
         * @throws RepositoryException if an error occurs accessing the repository
         */
        private AbstractJcrNode closestMatchFor( JcrVersionHistoryNode versionHistory,
                                                 DateTime checkinTime ) throws RepositoryException {
            DateTimeFactory dateFactory = session.context().getValueFactories().getDateFactory();

            VersionIterator iter = versionHistory.getAllVersions();
            Map<DateTime, Version> versions = new HashMap<DateTime, Version>((int)iter.getSize());

            while (iter.hasNext()) {
                Version version = iter.nextVersion();
                versions.put(dateFactory.create(version.getCreated()), version);
            }

            List<DateTime> versionDates = new ArrayList<DateTime>(versions.keySet());
            Collections.sort(versionDates);

View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.DateTimeFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.