Skip to content

Commit 838cdef

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 148101a + 2eb8452 commit 838cdef

13 files changed

+1252
-33
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.marklogic.javaclient;
2+
3+
import java.util.Calendar;
4+
5+
import com.marklogic.client.pojo.annotation.Id;
6+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
7+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
8+
9+
/*
10+
* This class is similar to the Artifact class. It is used to test path range index using the DateTime field
11+
* Property name been annotated with @Id.
12+
*/
13+
public class ArtifactIndexedOnDateTime {
14+
@Id
15+
public String name;
16+
public long id;
17+
private Company manufacturer;
18+
private int inventory;
19+
20+
@PathIndexProperty(scalarType = ScalarType.DATETIME)
21+
private Calendar expiryDate;
22+
23+
public long getId() {
24+
return id;
25+
}
26+
27+
public ArtifactIndexedOnDateTime setId(long id) {
28+
this.id = id;
29+
return this;
30+
}
31+
32+
public String getName() {
33+
return name;
34+
}
35+
36+
public ArtifactIndexedOnDateTime setName(String name) {
37+
this.name = name;
38+
return this;
39+
}
40+
41+
public Company getManufacturer() {
42+
return manufacturer;
43+
}
44+
45+
public ArtifactIndexedOnDateTime setManufacturer(Company manufacturer) {
46+
this.manufacturer = manufacturer;
47+
return this;
48+
}
49+
50+
public int getInventory() {
51+
return inventory;
52+
}
53+
54+
public ArtifactIndexedOnDateTime setInventory(int inventory) {
55+
this.inventory = inventory;
56+
return this;
57+
}
58+
59+
public Calendar getExpiryDate() {
60+
return expiryDate;
61+
}
62+
63+
public ArtifactIndexedOnDateTime setExpiryDate(Calendar expiryDate) {
64+
this.expiryDate = expiryDate;
65+
return this;
66+
}
67+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.Id;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
5+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
6+
7+
/*
8+
* This class is similar to the Artifact class. It is used to test path range index using the inventory field
9+
* Property name been annotated with @Id.
10+
*/
11+
public class ArtifactIndexedOnInt {
12+
@Id
13+
public String name;
14+
public long id;
15+
private Company manufacturer;
16+
17+
@PathIndexProperty(scalarType = ScalarType.INT)
18+
private int inventory;
19+
20+
public long getId() {
21+
return id;
22+
}
23+
24+
public ArtifactIndexedOnInt setId(long id) {
25+
this.id = id;
26+
return this;
27+
}
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
public ArtifactIndexedOnInt setName(String name) {
34+
this.name = name;
35+
return this;
36+
}
37+
38+
public Company getManufacturer() {
39+
return manufacturer;
40+
}
41+
42+
public ArtifactIndexedOnInt setManufacturer(Company manufacturer) {
43+
this.manufacturer = manufacturer;
44+
return this;
45+
}
46+
47+
public int getInventory() {
48+
return inventory;
49+
}
50+
51+
public ArtifactIndexedOnInt setInventory(int inventory) {
52+
this.inventory = inventory;
53+
return this;
54+
}
55+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.Id;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
5+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
6+
7+
/*
8+
* This class is similar to the Artifact class. It is used to test path range index using the id field
9+
* indexed as string.
10+
* Property name been annotated with @Id.
11+
*/
12+
public class ArtifactIndexedOnIntAsString {
13+
@Id
14+
public String name;
15+
public long id;
16+
private Company manufacturer;
17+
18+
// Note int is annotated as a string
19+
@PathIndexProperty(scalarType = ScalarType.STRING)
20+
private int inventory;
21+
22+
public long getId() {
23+
return id;
24+
}
25+
26+
public ArtifactIndexedOnIntAsString setId(long id) {
27+
this.id = id;
28+
return this;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public ArtifactIndexedOnIntAsString setName(String name) {
36+
this.name = name;
37+
return this;
38+
}
39+
40+
public Company getManufacturer() {
41+
return manufacturer;
42+
}
43+
44+
public ArtifactIndexedOnIntAsString setManufacturer(Company manufacturer) {
45+
this.manufacturer = manufacturer;
46+
return this;
47+
}
48+
49+
public int getInventory() {
50+
return inventory;
51+
}
52+
53+
public ArtifactIndexedOnIntAsString setInventory(int inventory) {
54+
this.inventory = inventory;
55+
return this;
56+
}
57+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.Id;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
5+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
6+
7+
/*
8+
* This class is similar to the Artifact class. It is used to test path range index on multiple class fields
9+
* Property name been annotated with @Id.
10+
*
11+
*/
12+
public class ArtifactIndexedOnMultipleFields {
13+
@Id
14+
@PathIndexProperty(scalarType = ScalarType.STRING)
15+
public String name;
16+
public long id;
17+
private Company manufacturer;
18+
19+
@PathIndexProperty(scalarType = ScalarType.INT)
20+
private int inventory;
21+
22+
public long getId() {
23+
return id;
24+
}
25+
26+
public ArtifactIndexedOnMultipleFields setId(long id) {
27+
this.id = id;
28+
return this;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public ArtifactIndexedOnMultipleFields setName(String name) {
36+
this.name = name;
37+
return this;
38+
}
39+
40+
public Company getManufacturer() {
41+
return manufacturer;
42+
}
43+
44+
public ArtifactIndexedOnMultipleFields setManufacturer(Company manufacturer) {
45+
this.manufacturer = manufacturer;
46+
return this;
47+
}
48+
49+
public int getInventory() {
50+
return inventory;
51+
}
52+
53+
public ArtifactIndexedOnMultipleFields setInventory(int inventory) {
54+
this.inventory = inventory;
55+
return this;
56+
}
57+
}
58+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.Id;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
5+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
6+
7+
/*
8+
* This class is similar to the Artifact class. It is used to test path range index using the name field
9+
* which has been annotated with @Id also.
10+
*/
11+
public class ArtifactIndexedOnString {
12+
@Id
13+
@PathIndexProperty(scalarType = ScalarType.STRING)
14+
public String name;
15+
16+
public long id;
17+
private Company manufacturer;
18+
private int inventory;
19+
20+
public long getId() {
21+
return id;
22+
}
23+
24+
public ArtifactIndexedOnString setId(long id) {
25+
this.id = id;
26+
return this;
27+
}
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
public ArtifactIndexedOnString setName(String name) {
34+
this.name = name;
35+
return this;
36+
}
37+
38+
public Company getManufacturer() {
39+
return manufacturer;
40+
}
41+
42+
public ArtifactIndexedOnString setManufacturer(Company manufacturer) {
43+
this.manufacturer = manufacturer;
44+
return this;
45+
}
46+
47+
public int getInventory() {
48+
return inventory;
49+
}
50+
51+
public ArtifactIndexedOnString setInventory(int inventory) {
52+
this.inventory = inventory;
53+
return this;
54+
}
55+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.marklogic.javaclient;
2+
3+
import java.net.URI;
4+
5+
import com.marklogic.client.pojo.annotation.Id;
6+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
7+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
8+
9+
/*
10+
* This class is similar to the Artifact class. It is used to test path range index using the URI field
11+
* Property name annotated with @Id.
12+
*/
13+
public class ArtifactIndexedOnUri {
14+
@Id
15+
public String name;
16+
17+
public long id;
18+
private Company manufacturer;
19+
private int inventory;
20+
21+
@PathIndexProperty(scalarType = ScalarType.ANYURI)
22+
private URI artifactUri;
23+
24+
public URI getArtifactUri() {
25+
return artifactUri;
26+
}
27+
28+
public void setArtifactUri(URI artifactUri) {
29+
this.artifactUri = artifactUri;
30+
}
31+
32+
public long getId() {
33+
return id;
34+
}
35+
36+
public ArtifactIndexedOnUri setId(long id) {
37+
this.id = id;
38+
return this;
39+
}
40+
41+
public String getName() {
42+
return name;
43+
}
44+
45+
public ArtifactIndexedOnUri setName(String name) {
46+
this.name = name;
47+
return this;
48+
}
49+
50+
public Company getManufacturer() {
51+
return manufacturer;
52+
}
53+
54+
public ArtifactIndexedOnUri setManufacturer(Company manufacturer) {
55+
this.manufacturer = manufacturer;
56+
return this;
57+
}
58+
59+
public int getInventory() {
60+
return inventory;
61+
}
62+
63+
public ArtifactIndexedOnUri setInventory(int inventory) {
64+
this.inventory = inventory;
65+
return this;
66+
}
67+
}

test-complete/src/test/java/com/marklogic/javaclient/ConnectedRESTQA.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,4 +1686,32 @@ public static void setupServerRequestLogging(DatabaseClient client,boolean flag)
16861686
scm.setServerRequestLogging(flag);
16871687
scm.writeConfiguration();
16881688
}
1689+
1690+
/*
1691+
* This method inserts a path range index, in a JsonNode object, into the database.
1692+
*
1693+
*/
1694+
public static void setPathRangeIndexInDatabase(String dbName, JsonNode jnode) throws IOException
1695+
{
1696+
try {
1697+
DefaultHttpClient client = new DefaultHttpClient();
1698+
client.getCredentialsProvider().setCredentials(
1699+
new AuthScope("localhost", 8002),
1700+
new UsernamePasswordCredentials("admin", "admin"));
1701+
1702+
HttpPut put = new HttpPut("http://localhost:8002"+ "/manage/v2/databases/"+dbName+"/properties?format=json");
1703+
put.addHeader("Content-type", "application/json");
1704+
put.setEntity(new StringEntity(jnode.toString()));
1705+
1706+
HttpResponse response = client.execute(put);
1707+
HttpEntity respEntity = response.getEntity();
1708+
if(respEntity != null){
1709+
String content = EntityUtils.toString(respEntity);
1710+
System.out.println(content);
1711+
}
1712+
}catch (Exception e) {
1713+
// writing error to Log
1714+
e.printStackTrace();
1715+
}
1716+
}
16891717
}

0 commit comments

Comments
 (0)