I am tring to use Lookback API. I want to get all features change during a release.
What I tried :
LookbackQuery query = lookbackApi.newSnapshotQuery();
query.addFindClause("_TypeHierarchy", "PortfolioItem");
query.addFindClause("ObjectID", "280075838440");
Map previousValue = new HashMap();
previousValue.put("$exists", "true");
query.addFindClause("_PreviousValues.Release", previousValue);
query.requireFields("_SnapshotDate", "_SnapshotNumber", "FormattedID",
"Name", "Release","_PreviousValues.Release").hydrateFields("Release, _PreviousValues.Release");
LookbackResult resultSet = query.execute();
I have this exception :
Exception in thread "main" com.rallydev.lookback.LookbackException:
Query Error: incomplete intersection between 'hydrate' clause of
[Release, _PreviousValues.Release] with 'fields' clause of
[_SnapshotNumber, _PreviousValues.Release, _SnapshotDate, FormattedID,
Release, Name] at
com.rallydev.lookback.LookbackResult.validate(LookbackResult.java:101)
at
com.rallydev.lookback.LookbackApi.executeQuery(LookbackApi.java:233)
at
com.rallydev.lookback.LookbackQuery.validateAndRun(LookbackQuery.java:243)
at com.rallydev.lookback.LookbackQuery.execute(LookbackQuery.java:59)
at fr.mipih.rally.TestLoockback.main(TestLoockback.java:38)
But when I tried directly via: https://eu1.rallydev.com/analytics/v2.0/service/rally/workspace/9396539899/artifact/snapshot/query.js?hydrate=["Release","_PreviousValues.Release"]&start=1&pagesize=2000&find={$and: [{"ObjectID": 280075838440},{"_PreviousValues.Release": {"$exists":true}}]}&fields=["_SnapshotDate","_SnapshotNumber","FormattedID","Name","Release","_PreviousValues.Release"]
then I get some results!
Could you help me please and show me what I did wrong ?
The issue is in query - please wrap each field quote:
query.requireFields("_SnapshotDate", "_SnapshotNumber", "FormattedID",
"Name", "Release","_PreviousValues.Release").hydrateFields("Release", "_PreviousValues.Release");
Related
Anyone has use class FilteredQueryBuilder to create a Cypher query in Java?
I'm trying to create this query using neo4j-ogm:
MATCH (n:Message) WHERE n.messageContext = 'RECEBER_BOLETO_EM_ABERTO'
MATCH (n)-[r0:NEXT]->(m) WHERE r0.response = 'SIM'
return m
Map<String, Object> parameters = new HashedMap<>();
parameters.put("messageContext", "RECEBER_BOLETO_EM_ABERTO");
parameters.put("response", "SIM");
Filters filtersNode = new Filters();
Filter filterStartNode = new Filter("messageContext", ComparisonOperator.EQUALS, "RECEBER_BOLETO_EM_ABERTO");
filterStartNode.setNestedEntityTypeLabel("Message");
filterStartNode.setNestedPropertyName("messageContext");
filterStartNode.setRelationshipDirection(Relationship.OUTGOING);
filterStartNode.setBooleanOperator(BooleanOperator.AND);
filtersNode.add(filterStartNode);
Filter filterEndNode = new Filter("response", ComparisonOperator.EQUALS, "SIM");
filterEndNode.setNestedPropertyName("response");
filterEndNode.setRelationshipDirection(Relationship.TYPE);
filterEndNode.setBooleanOperator(BooleanOperator.AND);
filtersNode.add(filterEndNode);
FilteredQuery fq = FilteredQueryBuilder.buildRelationshipQuery("NEXT", filtersNode);
fq.setReturnClause("return m");
The Builder class doesn't parse the parameters into cypher query and throw the exception as follow:
org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code:
Neo.ClientError.Statement.ParameterMissing; Description: Expected a
parameter named messageContext_messageContext_0
Thanks in advance.
The query builders are internal classes to OGM. Don't rely on them, they could change in the future. The use of Filters with the OGM session is fine though.
To build custom cypher queries, you might be interested by Cypher DSL.
I need to convert below working REST endpoint to java query
/rest-1.v1/Data/Timebox?Where=Schedule.ScheduledScopes.Name="Sample: Call Center Product"&sel=Workitems:Defect[AssetState='Closed'].Estimate.#Sum,Name,Workitems:Story[AssetState='Closed'].Estimate.#Sum
My Not working Code:
IAssetType storyType = services.getMeta().getAssetType("Timebox");
Query query = new Query(storyType, true);
IAttributeDefinition name = storyType.getAttributeDefinition("Name");
IAttributeDefinition defect_estimate = storyType.getAttributeDefinition("Workitems:Defect[AssetState='Closed'].Estimate.#Sum");
IAttributeDefinition story_estimate = storyType.getAttributeDefinition("Workitems:Story[AssetState='Closed'].Estimate.#Sum");
query.getSelection().add(name);
query.getSelection().add(defect_estimate);
query.getSelection().add(story_estimate);
//IFilterTerm activeSprint = new TokenTerm("State.Code='ACTV'");
IFilterTerm activeSprint = new TokenTerm("Schedule.ScheduledScopes.Name='Sample: Call Center Product'");
query.setFilter(activeSprint);
DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
QueryResult result = services.retrieve(query);
Error i am getting:
Exception in thread "main" com.versionone.apiclient.exceptions.MetaException: Unknown AttributeDefinition: Timebox.Workitems:Defect[AssetState='Closed'].Estimate.#Sum
at com.versionone.apiclient.MetaModel.getAttributeDefinition(MetaModel.java:119)
at com.versionone.apiclient.AssetType.getAttributeDefinition(AssetType.java:96)
at v1_rest_intig.Example1.main(Example1.java:230)
what am i doing wrong??
any guidance is of great help
Thanks in advance
You are using the right attribute definition, but apparently, at some version of the API they stop translating symbols, like brakets '[' into the URL encoding ( '%5B' for open bracket) and therefore the resulting error message.
Please, try this instead:
Workitems:Defect%5BAssetState=%27128%27%5D
for your attributes definition for the Defect/Story AssetType.
Let me know if this works.
TIA,
I'm new to ArangoDB and trying to do a few very basic queries. I was successful to add vertices and edges, but the query retrieving edges always throws an exception. I tried a few different queries from the (very minimalistic) documentation and it always throws the same. Here is one of the queries:
CursorEntity<BaseDocument> r = arangoDriver.graphGetEdges("MyGraph", BaseDocument.class, "Person/1");
while (r.iterator().hasNext()){
BaseDocument d = r.iterator().next();
System.out.println(d.getDocumentHandle());
}
Or this one with the same exception:
String query = "for i in GRAPH_EDGES(#graphName, #vertexId, {direction: 'outbound', edgeCollectionRestriction: 'Friends'}) return i";
Map<String, Object> bindVars = new MapBuilder().put("graphName", "MyGraph").put("vertexId", "Person/1").get();
CursorEntity<PlainEdgeEntity> result;
try {
result = arangoDriver.executeQuery(query, bindVars, PlainEdgeEntity.class ,true, 10);
And here the exception:
Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:803)
at com.google.gson.Gson.fromJson(Gson.java:868)
at com.google.gson.Gson$1.deserialize(Gson.java:126)
at com.arangodb.entity.EntityDeserializers$CursorEntityDeserializer.deserialize(EntityDeserializers.java:519)
at com.arangodb.entity.EntityDeserializers$CursorEntityDeserializer.deserialize(EntityDeserializers.java:488)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
at com.google.gson.Gson.fromJson(Gson.java:803)
at com.google.gson.Gson.fromJson(Gson.java:768)
at com.google.gson.Gson.fromJson(Gson.java:717)
at com.arangodb.entity.EntityFactory.createEntity(EntityFactory.java:109)
at com.arangodb.BaseArangoDriver.createEntityImpl(BaseArangoDriver.java:270)
at com.arangodb.BaseArangoDriver.createEntity(BaseArangoDriver.java:181)
at com.arangodb.BaseArangoDriver.createEntity(BaseArangoDriver.java:219)
at com.arangodb.impl.InternalCursorDriverImpl.executeQuery(InternalCursorDriverImpl.java:78)
at com.arangodb.ArangoDriver.executeQuery(ArangoDriver.java:1877)
at com.arangodb.ArangoDriver.graphGetEdges(ArangoDriver.java:4135)
at x.y.z.database.arangodb.Arango.main(Arango.java:34)
I almost think it is a bug? Maybe a problem with newest versions? Or do i miss something?
Using latest versions.. 2.6.8 and driver 2.5.7
Update: if I use a nonexistent ID it returns zero results without exception and if i use an existing ID the same exception is thrown. that tells me that i used the right parameters, and the problem is most likely a bug..
As stj pointed out, there's a driver release fixing the initial problem: http://github.com/arangodb/arangodb-java-driver/releases .
That should work fine with the following code:
CursorEntity<BaseDocument> r = driver.graphGetEdges("myGraph",
BaseDocument.class, "Person/1");
Iterator<BaseDocument> it = r.iterator();
while {
it.hasNext()) {
BaseDocument d = it.next();
System.out.println(d.getDocumentHandle());
}
}
The example code while (r.iterator().hasNext()) { ... } won't work because it will create a new Iterator object in each iteration and thus never finish
We added more examples howto work with ArangoDB graphs in java to the learn more section of the README
First my setups :
mysql-connector-java 5.1.24
hibernate-core 4.1.10.Final
I've got an ClassCastException when running this criteria query :
Criteria sellableItemsCriteria = session.createCriteria(MarketData.class, "md");
sellableItemsCriteria.add(Restrictions.in("region", regions));
sellableItemsCriteria.add(Restrictions.in("itemTypeId", items));
DetachedCriteria sellOrderSizeCriteria = DetachedCriteria.forClass(MarketOrder.class);
sellOrderSizeCriteria.add(Restrictions.eq("marketDataId", "md.id"));
sellOrderSizeCriteria.add(Restrictions.eq("bid", false));
sellOrderSizeCriteria.setProjection(Projections.count("marketDataId"));
sellableItemsCriteria.add(Subqueries.lt(0L, sellOrderSizeCriteria));
The exception :
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
The problem is from this line (first i tried with 0 instead of 0L and i got Integer cannot be cast to Long so that why i switched to a Long) :
sellableItemsCriteria.add(Subqueries.lt(0L, sellOrderSizeCriteria));
And this is the mysql query i want to run :
SELECT md.* FROM `marketdata` md
WHERE md.region IN (:regions)
AND md.item_typeID IN (:items)
AND (SELECT COUNT(marketData_id) FROM `marketorder` WHERE marketData_id = md.id AND bid = 0) > 0
How can i resolve the cast problem ?
Or maybe there is a better way to do this with Criteria ?
Thanks
I'm pretty sure you'll find that the exception comes in fact from this line:
sellOrderSizeCriteria.add(Restrictions.eq("marketDataId", "md.id"));
This line tries to compare the marketDataId property of MarketOrder to the String "md.id". That's not what you want to do. What you want to do is to compare the marketDataId property of MarketOrder to the id property of md. And you thus need to use eqProperty() instead:
sellOrderSizeCriteria.add(Restrictions.eqProperty("marketDataId", "md.id"));
Can someone please tell me how to get a Text value out of a Google App Engine datastore using Java? I have some entities in the datastore with a Text property named longDescription. When I try this:
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query q = new Query("Items");
PreparedQuery pq = ds.prepare(q);
for (Entity result : pq.asIterable()) {
Text longDescription = (Text)result.getProperty("longDescription");
}
I'm getting this warning on the longDescription assignment line:
WARNING: /pstest
java.lang.ClassCastException: java.lang.String cannot be cast to
com.google.appengine.api.datastore.Text
I'm absolutely bumfuzzled here. The only string in my code is the literal "longDescription" that is used to fetch the correct property. If I put this just above the assignment line:
log.warning("Type is " + (result.getProperty("longDescription")).getClass());
I see the following output:
WARNING: Type is class com.google.appengine.api.datastore.Text
Okay, so result.getProperty("longDescription") really, really is a Text object that is being passed back as an object. I've even tried using the fully qualified name (com.google.appengine.api.datastore.Text) instead of just Text with the same results. Where is the String cast coming in? And more importantly, how do I get that Text out of the datastore? I'm at my wit's end here, and any help would be appreciated!
Oh, one other possibly relevant note: This is the assignment I used when inserting the property into the datastore:
Entity eItem = new Entity("Items");
eItem.setProperty("longDescription", new Text(req.getParameter("ldes")));
ds.put(eItem);
When I look at the description in my management console, it seems to be over 500 characters, and it's displayed like this:
<Text: This is a long form description of an item in the store that is access...>
Did I screw something up when inserting it? If so, how do you insert Text items into the datastore?
I figured out the problem, Wei Hao was right in the comments above. It seems that at some point, I inserted a test String as a longDescription instead of a Text. I'm going to chalk this up to being a lesson learned from the school of hard knocks due to being a bit of a noob with the datastore.
For anyone else who runs across this question, the answer is: If you're iterating over a list of query results, make sure that you're getting back what you expect on every result that comes back! Remember, this isn't an RDBMS and every entity can have a different datatype for the same property. So yes, you can have 1,572,394 entities in which longDescription is a Text and one entity in which longDescription is a String, and this will hose you up.
Here's a little code snippet that probably would help to diagnose this issue:
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query q = new Query("Items");
PreparedQuery pq = ds.prepare(q);
for (Entity result : pq.asIterable()) {
if (longDescription isinstanceof Text)
Text longDescription = (Text)result.getProperty("longDescription");
else
log.severe("Unexpected datatype: longDescription is a "
+ result.getProperty("longDescription").getClass().toString());
}
Here's my code;
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query q = new Query(entityKind);
PreparedQuery pq = ds.prepare(q);
for (Entity e : pq.asIterable()) {
String longtext = ((Text)e.getProperty("somelongdescription")).getValue();}