Examples of SelectResult


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

        if (continueFromLastRun)
            request.setNextToken((String)query.nextKey);

        try {
            SelectResult    result = sdbClient.select(request);
            query.nextKey = request.getNextToken();
            for (Item item : result.getItems()) {
                String      idValue = item.getName();   // get the id from the item's name()
                T           obj = buildLoadObj(modelClass, query.modelName, idValue, item.getAttributes(), query);
                resultObjs.add(obj);
            }
            return resultObjs;
View Full Code Here

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

// String qToSend = amazonQuery != null ? amazonQuery.toString() : null;
            em.incrementQueryCount();
            if (amazonQuery.isCount()) {
// String domainName = em.getDomainName(tClass);
                String nextToken = null;
                SelectResult qr;
                long count = 0;

                while ((qr = DomainHelper.selectItems(this.em.getSimpleDb(), amazonQuery.getValue(), nextToken)) != null) {
                    Map<String, List<Attribute>> itemMap = new HashMap<String, List<Attribute>>();
                    for (Item item : qr.getItems()) {
                        itemMap.put(item.getName(), item.getAttributes());
                    }

                    for (String id : itemMap.keySet()) {
                        List<Attribute> list = itemMap.get(id);
                        for (Attribute itemAttribute : list) {
                            if (itemAttribute.getName().equals("Count")) {
                                count += Long.parseLong(itemAttribute.getValue());
                            }
                        }
                    }
                    nextToken = qr.getNextToken();
                    if (nextToken == null) {
                        break;
                    }
                }
                return Arrays.asList(count);
View Full Code Here

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

    public void renameField(Class tClass, String oldAttributeName, String newAttributeName) {
        // get list of all items in the domain
        try {
            String domainName = getDomainName(tClass);
            SelectResult result;
            List<Item> items;
            int i = 0;
            String nextToken = null;
            while (i == 0 || nextToken != null) {
                result = executeQueryForRename(oldAttributeName, newAttributeName, domainName, nextToken);
                items = result.getItems();
                putAndDelete(domainName, oldAttributeName, newAttributeName, items);
                nextToken = result.getNextToken();
                i++;
                if (i % 100 == 0) {
                    System.out.println("Renamed " + i + " fields so far...");
                }
            }
View Full Code Here

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

    public void renameSubclass(String oldClassName, Class newClass) {
        logger.info("Renaming DTYPE for " + oldClassName + " to " + newClass.getSimpleName());
        try {
            String newClassName = newClass.getSimpleName();
            String domainName = factory.getDomainName(newClass);
            SelectResult result;
            List<Item> items;
            int i = 0;
            String nextToken = null;
            while (i == 0 || nextToken != null) {
                result = executeQueryForRenameSubclass(oldClassName, newClass, domainName, nextToken);
                items = result.getItems();
                putNewValue(domainName, items, EntityManagerFactoryImpl.DTYPE, newClassName);
                nextToken = result.getNextToken();
                i++;
                if (i % 100 == 0) {
                    System.out.println("Renamed " + i + " subclassed objects so far...");
                }
            }
View Full Code Here

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

            db.putAttributes(new PutAttributesRequest(domainName, item.getName(), atts));
        }
    }

    private SelectResult executeQueryForRenameSubclass(String oldClassName, Class newClass, String domainName, String nextToken) throws AmazonClientException {
        SelectResult result = DomainHelper.selectItems(factory.getSimpleDb(), domainName, "'DTYPE' = '" + oldClassName + "'", nextToken, consistentRead);
        return result;
    }
View Full Code Here

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

        return result;
    }

    private SelectResult executeQueryForRename(String oldAttributeName, String newAttributeName, String domainName, String nextToken)
            throws AmazonClientException {
        SelectResult result = DomainHelper.selectItems(factory.getSimpleDb(), domainName, "['" + oldAttributeName + "' starts-with ''] intersection not ['"
                + newAttributeName + "' starts-with ''] ", nextToken, consistentRead);
        return result;
    }
View Full Code Here

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

        Date expectedTerminationTime = new Date(now.plusDays(10).getMillis());
        Date markTime = new Date(now.getMillis());
        String fieldName = "fieldName123";
        String fieldValue = "fieldValue456";

        SelectResult result1 = mkSelectResult(id1, resourceType, state, description, ownerEmail,
                region, terminationReason, expectedTerminationTime, markTime, false, fieldName, fieldValue);
        result1.setNextToken("nextToken");
        SelectResult result2 = mkSelectResult(id2, resourceType, state, description, ownerEmail,
                region, terminationReason, expectedTerminationTime, markTime, true, fieldName, fieldValue);

        ArgumentCaptor<SelectRequest> arg = ArgumentCaptor.forClass(SelectRequest.class);

        TestSimpleDBJanitorResourceTracker tracker = new TestSimpleDBJanitorResourceTracker();
View Full Code Here

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

        attrs.add(new Attribute(AWSResource.FIELD_OPT_OUT_OF_JANITOR, String.valueOf(optOut)));
        attrs.add(new Attribute(fieldName, fieldValue));

        item.setAttributes(attrs);
        item.setName(String.format("%s-%s-%s", resourceType.name(), id, region));
        SelectResult result = new SelectResult();
        result.setItems(Arrays.asList(item));
        return result;
    }
View Full Code Here

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

        List<Item> items = new ArrayList<Item>();
        do {
            SelectRequest request = new SelectRequest(query);
            request.setNextToken(nextToken);
            request.setConsistentRead(Boolean.TRUE);
            SelectResult result = this.simpleDBClient.select(request);
            items.addAll(result.getItems());
            nextToken = result.getNextToken();
        } while (nextToken != null);

        return items;
    }
View Full Code Here

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

        List<Event> list = new LinkedList<Event>();
        SelectRequest request = new SelectRequest(query.toString());
        request.setConsistentRead(Boolean.TRUE);

        SelectResult result = new SelectResult();
        do {
            result = sdbClient().select(request.withNextToken(result.getNextToken()));
            for (Item item : result.getItems()) {
                Map<String, String> fields = new HashMap<String, String>();
                Map<String, String> res = new HashMap<String, String>();
                for (Attribute attr : item.getAttributes()) {
                    if (Keys.KEYSET.contains(attr.getName())) {
                        res.put(attr.getName(), attr.getValue());
                    } else {
                        fields.put(attr.getName(), attr.getValue());
                    }
                }
                String eid = res.get(Keys.id.name());
                String ereg = res.get(Keys.region.name());
                MonkeyType monkeyType = valueToEnum(MonkeyType.class, res.get(Keys.monkeyType.name()));
                EventType eventType = valueToEnum(EventType.class, res.get(Keys.eventType.name()));
                long eventTime = Long.parseLong(res.get(Keys.eventTime.name()));
                list.add(new BasicRecorderEvent(monkeyType, eventType, ereg, eid, eventTime).addFields(fields));
            }
        } while (result.getNextToken() != null);
        return list;
    }
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.