Examples of UpdateCondition


Examples of com.amazonaws.services.simpledb.model.UpdateCondition

   
    @Test
    public void putAttributesItemNameIsRequired() {
        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
            new ReplaceableAttribute("NAME1", "VALUE1", true)});
        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
       
        Exchange exchange = template.send("direct:start-sdb", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

        if (expectedValue == null)
            throw new IllegalArgumentException("ExpectedValue cannot be null.");

        String          attrName = jsoda.getFieldAttrMap(modelName).get(expectedField);
        String          fieldValue = DataUtil.encodeValueToAttrStr(expectedValue, jsoda.getField(modelName, expectedField).getType());
        UpdateCondition cond = new UpdateCondition();

        cond.setExists(expectedExists);
        cond.setName(attrName);
        if (expectedExists) {
            cond.setValue(fieldValue);
        }
        return cond;
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

            InvocationTargetException, IOException {
        long start = System.currentTimeMillis();
        em.invokeEntityListener(o, newObject ? PrePersist.class : PreUpdate.class);
        AnnotationInfo ai = em.getFactory().getAnnotationManager().getAnnotationInfo(o);

        UpdateCondition expected = null;
        PersistentProperty versionField = null;
        Long nextVersion = -1L;

        String domainName;
        if (ai.getRootClass() != null) {
            domainName = em.getOrCreateDomain(ai.getRootClass());
        } else {
            domainName = em.getOrCreateDomain(o.getClass());
        }
        // Item item = DomainHelper.findItemById(this.em.getSimpleDb(),
        // domainName, id);
        // now set attributes
        List<ReplaceableAttribute> attsToPut = new ArrayList<ReplaceableAttribute>();
        List<Attribute> attsToDelete = new ArrayList<Attribute>();
        if (ai.getDiscriminatorValue() != null) {
            attsToPut.add(new ReplaceableAttribute(EntityManagerFactoryImpl.DTYPE, ai.getDiscriminatorValue(), true));
        }

        LazyInterceptor interceptor = null;
        if (o instanceof Factory) {
            Factory factory = (Factory) o;
            /*
             * for (Callback callback2 : factory.getCallbacks()) {
             * if(logger.isLoggable(Level.FINER)) logger.finer("callback=" +
             * callback2); if (callback2 instanceof LazyInterceptor) {
             * interceptor = (LazyInterceptor) callback2; } }
             */
            interceptor = (LazyInterceptor) factory.getCallback(0);
        }

        for (PersistentProperty field : ai.getPersistentProperties()) {
            Object ob = field.getProperty(o);

            String columnName = field.getColumnName();
            if (ob == null) {
                attsToDelete.add(new Attribute(columnName, null));
                continue;
            }
            if (field.isForeignKeyRelationship()) {
                // store the id of this object
                if (Collection.class.isAssignableFrom(field.getRawClass())) {
                    for (Object each : (Collection) ob) {
                        String id2 = em.getId(each);
                        attsToPut.add(new ReplaceableAttribute(columnName, id2, true));
                    }
                } else {
                    String id2 = em.getId(ob);
                    attsToPut.add(new ReplaceableAttribute(columnName, id2, true));

                    /* check if we should persist this */
                    boolean persistRelationship = false;
                    ManyToOne a = field.getGetter().getAnnotation(ManyToOne.class);
                    if (a != null && null != a.cascade()) {
                        CascadeType[] cascadeType = a.cascade();
                        for (CascadeType type : cascadeType) {
                            if (CascadeType.ALL == type || CascadeType.PERSIST == type) {
                                persistRelationship = true;
                            }
                        }
                    }
                    if (persistRelationship) {
                        em.persist(ob);
                    }
                }
            } else if (field.isVersioned()) {
                Long curVersion = Long.parseLong("" + ob);
                nextVersion = (1 + curVersion);

                attsToPut.add(new ReplaceableAttribute(columnName, em.padOrConvertIfRequired(nextVersion), true));

                if (curVersion > 0) {
                    expected = new UpdateCondition(columnName, em.padOrConvertIfRequired(curVersion), true);
                } else {
                    expected = new UpdateCondition().withName(columnName).withExists(false);
                }

                versionField = field;
            } else if (field.isInverseRelationship()) {
                // FORCING BI-DIRECTIONAL RIGHT NOW SO JUST IGNORE
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

     */
    public void registerInstance(PriamInstance instance) throws AmazonServiceException
    {
        AmazonSimpleDBClient simpleDBClient = getSimpleDBClient();
        PutAttributesRequest putReq = new PutAttributesRequest(DOMAIN, getKey(instance), createAttributesToRegister(instance));
        UpdateCondition expected = new UpdateCondition();
        expected.setName(Attributes.INSTANCE_ID);
        expected.setExists(false);
        putReq.setExpected(expected);
        simpleDBClient.putAttributes(putReq);
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

            valueParameter = expectNode.get("value").asText();

        if (null != expectNode.get("exists"))
            existsParameter = Boolean.valueOf(expectNode.get("exists").asBoolean());

        return new UpdateCondition(nameParameter, valueParameter, existsParameter);
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

            InvocationTargetException, IOException {
        long start = System.currentTimeMillis();
        em.invokeEntityListener(o, newObject ? PrePersist.class : PreUpdate.class);
        AnnotationInfo ai = em.getFactory().getAnnotationManager().getAnnotationInfo(o);

        UpdateCondition expected = null;
        PersistentProperty versionField = null;
        Integer nextVersion = -1;

        String domainName;
        if (ai.getRootClass() != null) {
            domainName = em.getOrCreateDomain(ai.getRootClass());
        } else {
            domainName = em.getOrCreateDomain(o.getClass());
        }
        // Item item = DomainHelper.findItemById(this.em.getSimpleDb(),
        // domainName, id);
        // now set attributes
        List<ReplaceableAttribute> attsToPut = new ArrayList<ReplaceableAttribute>();
        List<Attribute> attsToDelete = new ArrayList<Attribute>();
        if (ai.getDiscriminatorValue() != null) {
            attsToPut.add(new ReplaceableAttribute(EntityManagerFactoryImpl.DTYPE, ai.getDiscriminatorValue(), true));
        }

        LazyInterceptor interceptor = null;
        if (o instanceof Factory) {
            Factory factory = (Factory) o;
            /*
             * for (Callback callback2 : factory.getCallbacks()) {
             * if(logger.isLoggable(Level.FINER)) logger.finer("callback=" +
             * callback2); if (callback2 instanceof LazyInterceptor) {
             * interceptor = (LazyInterceptor) callback2; } }
             */
            interceptor = (LazyInterceptor) factory.getCallback(0);
        }

        for (PersistentProperty field : ai.getPersistentProperties()) {
            Object ob = field.getProperty(o);

            String columnName = field.getColumnName();
            if (ob == null) {
                attsToDelete.add(new Attribute(columnName, null));
                continue;
            }
            if (field.isForeignKeyRelationship()) {
                // store the id of this object
                if (Collection.class.isAssignableFrom(field.getRawClass())) {
                    for (Object each : (Collection) ob) {
                        String id2 = em.getId(each);
                        attsToPut.add(new ReplaceableAttribute(columnName, id2, true));
                    }
                } else {
                    String id2 = em.getId(ob);
                    attsToPut.add(new ReplaceableAttribute(columnName, id2, true));

                    /* check if we should persist this */
                    boolean persistRelationship = false;
                    ManyToOne a = field.getGetter().getAnnotation(ManyToOne.class);
                    if (a != null && null != a.cascade()) {
                        CascadeType[] cascadeType = a.cascade();
                        for (CascadeType type : cascadeType) {
                            if (CascadeType.ALL == type || CascadeType.PERSIST == type) {
                                persistRelationship = true;
                            }
                        }
                    }
                    if (persistRelationship) {
                        em.persist(ob);
                    }
                }
            } else if (field.isVersioned()) {
                Integer curVersion = Integer.parseInt("" + ob);
                nextVersion = (1 + curVersion);

                attsToPut.add(new ReplaceableAttribute(columnName, em.padOrConvertIfRequired(nextVersion), true));

                if (curVersion > 0)
                    expected = new UpdateCondition(columnName, em.padOrConvertIfRequired(curVersion), true);

                versionField = field;
            } else if (field.isInverseRelationship()) {
                // FORCING BI-DIRECTIONAL RIGHT NOW SO JUST IGNORE
                // ... except for cascading persistence down to all items in the
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.UpdateCondition

            valueParameter = expectNode.get("value").asText();

        if (null != expectNode.get("exists"))
            existsParameter = Boolean.valueOf("" + expectNode.get("exists"));

        return new UpdateCondition(nameParameter, valueParameter, existsParameter);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.