@Override public List<IDeviceGroupElement> addDeviceGroupElements(String groupToken, List<IDeviceGroupElementCreateRequest> elements, boolean ignoreDuplicates) throws SiteWhereException { List<IDeviceGroupElement> results = new ArrayList<IDeviceGroupElement>(); for (IDeviceGroupElementCreateRequest request : elements) { long index = MongoDeviceGroup.getNextGroupIndex(getMongoClient(), getTenant(), groupToken); DeviceGroupElement element = SiteWherePersistence.deviceGroupElementCreateLogic(request, groupToken, index); Document created = MongoDeviceGroupElement.toDocument(element); try { MongoPersistence.insert(getMongoClient().getGroupElementsCollection(getTenant()), created, ErrorCode.DuplicateId); results.add(MongoDeviceGroupElement.fromDocument(created)); } catch (ResourceExistsException e) { if (!ignoreDuplicates) { throw e; } } } return results; }
DeviceGroupElement element = SiteWherePersistence.deviceGroupElementCreateLogic(request, groupToken, index);