Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit ce1c6d1

Browse files
author
Achim Brandt
committed
fixed some sonar issues
1 parent 8e14db1 commit ce1c6d1

File tree

4 files changed

+137
-54
lines changed

4 files changed

+137
-54
lines changed

src/main/java/com/arangodb/blueprints/batch/ArangoDBBatchEdge.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ public class ArangoDBBatchEdge extends ArangoDBBatchElement implements Edge {
3939
*/
4040
private Vertex inVertex = null;
4141

42-
static ArangoDBBatchEdge create(ArangoDBBatchGraph graph, Object id, Vertex outVertex, Vertex inVertex, String label) {
42+
private ArangoDBBatchEdge(ArangoDBBatchGraph graph, ArangoDBSimpleEdge edge, Vertex outVertex, Vertex inVertex) {
43+
this.graph = graph;
44+
this.document = edge;
45+
this.outVertex = outVertex;
46+
this.inVertex = inVertex;
47+
}
48+
49+
static ArangoDBBatchEdge create(
50+
ArangoDBBatchGraph graph,
51+
Object id,
52+
Vertex outVertex,
53+
Vertex inVertex,
54+
String label) {
4355
String key = (id != null) ? id.toString() : null;
4456

4557
if (key == null) {
@@ -59,10 +71,10 @@ static ArangoDBBatchEdge create(ArangoDBBatchGraph graph, Object id, Vertex outV
5971
properties.put(StringFactory.LABEL, label);
6072
}
6173

62-
properties.put(ArangoDBSimpleEdge._FROM, graph.getRawGraph().getVertexCollection() + "/"
63-
+ from.getRawVertex().getDocumentKey());
64-
properties.put(ArangoDBSimpleEdge._TO, graph.getRawGraph().getVertexCollection() + "/"
65-
+ to.getRawVertex().getDocumentKey());
74+
properties.put(ArangoDBSimpleEdge._FROM,
75+
graph.getRawGraph().getVertexCollection() + "/" + from.getRawVertex().getDocumentKey());
76+
properties.put(ArangoDBSimpleEdge._TO,
77+
graph.getRawGraph().getVertexCollection() + "/" + to.getRawVertex().getDocumentKey());
6678

6779
try {
6880
ArangoDBSimpleEdge v = new ArangoDBSimpleEdge(properties);
@@ -118,17 +130,12 @@ static ArangoDBBatchEdge build(
118130
return newEdge;
119131
}
120132

121-
private ArangoDBBatchEdge(ArangoDBBatchGraph graph, ArangoDBSimpleEdge edge, Vertex outVertex, Vertex inVertex) {
122-
this.graph = graph;
123-
this.document = edge;
124-
this.outVertex = outVertex;
125-
this.inVertex = inVertex;
126-
}
127-
133+
@Override
128134
public Vertex getVertex(Direction direction) throws IllegalArgumentException {
129135
throw new UnsupportedOperationException();
130136
}
131137

138+
@Override
132139
public String getLabel() {
133140
Object l = document.getProperty(StringFactory.LABEL);
134141
if (l != null) {
@@ -152,13 +159,15 @@ public String toString() {
152159
return StringFactory.edgeString(this);
153160
}
154161

162+
@Override
155163
public void remove() {
156164
throw new UnsupportedOperationException();
157165
}
158166

159167
/**
160168
* not supported in batch mode
161169
*/
170+
@Override
162171
public void save() {
163172
throw new UnsupportedOperationException();
164173
}

src/main/java/com/arangodb/blueprints/batch/ArangoDBBatchElement.java

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.HashSet;
44
import java.util.Set;
55

6+
import org.apache.log4j.Logger;
7+
68
import com.arangodb.blueprints.client.ArangoDBBaseDocument;
79
import com.arangodb.blueprints.client.ArangoDBException;
810
import com.arangodb.blueprints.utils.ArangoDBUtil;
@@ -19,7 +21,12 @@
1921
* @author Guido Schwab (http://www.triagens.de)
2022
*/
2123

22-
abstract public class ArangoDBBatchElement implements Element {
24+
abstract class ArangoDBBatchElement implements Element {
25+
26+
/**
27+
* the logger
28+
*/
29+
private static final Logger logger = Logger.getLogger(ArangoDBBatchElement.class);
2330

2431
/**
2532
* the graph of the document
@@ -46,7 +53,7 @@ abstract public class ArangoDBBatchElement implements Element {
4653
* if an error occurs
4754
*/
4855

49-
abstract public void save() throws ArangoDBException;
56+
public abstract void save() throws ArangoDBException;
5057

5158
/**
5259
* Return the object value associated with the provided string key. If no
@@ -56,6 +63,7 @@ abstract public class ArangoDBBatchElement implements Element {
5663
* the key of the key/value property
5764
* @return the object value related to the string key
5865
*/
66+
@Override
5967
public Object getProperty(String key) {
6068
return document.getProperty(ArangoDBUtil.normalizeKey(key));
6169
}
@@ -70,6 +78,7 @@ public void setDocument(ArangoDBBaseDocument document) {
7078
this.document = document;
7179
}
7280

81+
@Override
7382
public Set<String> getPropertyKeys() {
7483
Set<String> ps = document.getPropertyKeys();
7584
HashSet<String> result = new HashSet<String>();
@@ -79,44 +88,57 @@ public Set<String> getPropertyKeys() {
7988
return result;
8089
}
8190

91+
@Override
8292
public void setProperty(String key, Object value) {
8393
if (created) {
8494
throw new UnsupportedOperationException();
8595
}
8696

87-
if (key == null || key.equals(StringFactory.EMPTY_STRING))
97+
if (isEmptyString(key))
8898
throw ExceptionFactory.propertyKeyCanNotBeEmpty();
8999
if (key.equals(StringFactory.ID))
90100
throw ExceptionFactory.propertyKeyIdIsReserved();
91101

92102
try {
93103
document.setProperty(ArangoDBUtil.normalizeKey(key), value);
94104
} catch (ArangoDBException e) {
105+
logger.warn("could not set property", e);
95106
throw new IllegalArgumentException(e.getMessage());
96107
}
97108
}
98109

110+
@Override
99111
public Object removeProperty(String key) {
112+
checkRemovePropertyKey(key);
113+
114+
Object o = null;
115+
try {
116+
o = document.removeProperty(ArangoDBUtil.normalizeKey(key));
117+
} catch (ArangoDBException e) {
118+
logger.warn("could not remove property", e);
119+
throw new IllegalArgumentException(e.getMessage());
120+
}
121+
return o;
122+
}
123+
124+
private void checkRemovePropertyKey(String key) {
100125
if (created) {
101126
throw new UnsupportedOperationException();
102127
}
103128

104-
if (key == null || key.equals(StringFactory.EMPTY_STRING))
129+
if (isEmptyString(key))
105130
throw ExceptionFactory.propertyKeyCanNotBeEmpty();
106131
if (key.equals(StringFactory.ID))
107132
throw ExceptionFactory.propertyKeyIdIsReserved();
108133
if (key.equals(StringFactory.LABEL) && this instanceof Edge)
109134
throw ExceptionFactory.propertyKeyLabelIsReservedForEdges();
135+
}
110136

111-
Object o = null;
112-
try {
113-
o = document.removeProperty(ArangoDBUtil.normalizeKey(key));
114-
} catch (ArangoDBException e) {
115-
throw new IllegalArgumentException(e.getMessage());
116-
}
117-
return o;
137+
private boolean isEmptyString(String key) {
138+
return key == null || key.equals(StringFactory.EMPTY_STRING);
118139
}
119140

141+
@Override
120142
public Object getId() {
121143
return document.getDocumentKey();
122144
}

0 commit comments

Comments
 (0)