MCPcopy Create free account
hub / github.com/annmuor/jnode / add

Method add

jnode-core/src/jnode/robot/AreaFix.java:272–324  ·  view source on GitHub ↗
(Link link, String area)

Source from the content-addressed store, hash-verified

270 }
271
272 private String add(Link link, String area) throws SQLException {
273 StringBuilder sb = new StringBuilder();
274 String like = area.replace("*", "%");
275 String[] grps = FtnTools.getOptionStringArray(link,
276 LinkOption.SARRAY_LINK_GROUPS);
277 List<Echoarea> areas = ORMManager.get(Echoarea.class).getAnd("name",
278 "~", like);
279 if (areas.isEmpty()) {
280 // check-check: let's make an request
281 // TODO: make it :-)
282 // Link uplink = ORMManager
283 // .get(Link.class)
284 // .join(true)
285 // .join(LinkOption.class, true, "name", "=",
286 // LinkOption.BOOLEAN_FORWARD_AREAFIX, "value", "=",
287 // "true").one();
288 sb.append(area + " not found");
289 } else {
290 for (Echoarea earea : areas) {
291 sb.append(earea.getName());
292 Subscription sub = ORMManager.get(Subscription.class)
293 .getFirstAnd("echoarea_id", "=", earea.getId(),
294 "link_id", "=", link.getId());
295 if (sub != null) {
296 sb.append(" already subscribed");
297 } else {
298 boolean denied = true;
299 if (!"".equals(earea.getGroup())) {
300 for (String group : grps) {
301 if (earea.getGroup().equals(group)) {
302 denied = false;
303 break;
304 }
305 }
306 } else {
307 denied = false;
308 }
309 if (denied) {
310 sb.append(" access denied");
311 } else {
312 sub = new Subscription();
313 sub.setArea(earea);
314 sub.setLink(link);
315 ORMManager.get(Subscription.class).save(sub);
316 sb.append(" subscribed");
317 }
318 }
319 sb.append('\n');
320 }
321 }
322 sb.append('\n');
323 return sb.toString();
324 }
325
326 private String rem(Link link, String area) throws SQLException {
327 StringBuilder sb = new StringBuilder();

Callers 3

executeMethod · 0.95
asIntListMethod · 0.45
storeMethod · 0.45

Calls 14

getOptionStringArrayMethod · 0.95
getMethod · 0.95
setAreaMethod · 0.95
setLinkMethod · 0.95
getAndMethod · 0.80
isEmptyMethod · 0.80
appendMethod · 0.80
getFirstAndMethod · 0.80
saveMethod · 0.80
getIdMethod · 0.65
getNameMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected