List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:org.syncope.client.validation.SyncopeClientErrorHandler.java
@Override public void handleError(final ClientHttpResponse response) throws IOException { if (!ArrayUtils.contains(MANAGED_STATUSES, response.getStatusCode())) { super.handleError(response); }/*from w w w . jav a 2s .com*/ List<String> exceptionTypesInHeaders = response.getHeaders().get(EXCEPTION_TYPE_HEADER); if (exceptionTypesInHeaders == null) { LOG.debug("No " + EXCEPTION_TYPE_HEADER + " provided"); return; } SyncopeClientCompositeErrorException compositeException = new SyncopeClientCompositeErrorException( response.getStatusCode()); Set<String> handledExceptions = new HashSet<String>(); for (String exceptionTypeAsString : exceptionTypesInHeaders) { SyncopeClientExceptionType exceptionType = null; try { exceptionType = SyncopeClientExceptionType.getFromHeaderValue(exceptionTypeAsString); } catch (IllegalArgumentException e) { LOG.error("Unexpected value of " + EXCEPTION_TYPE_HEADER + ": " + exceptionTypeAsString, e); } if (exceptionType != null) { handledExceptions.add(exceptionTypeAsString); SyncopeClientException clientException = new SyncopeClientException(); clientException.setType(exceptionType); if (response.getHeaders().get(exceptionType.getElementHeaderName()) != null && !response.getHeaders().get(exceptionType.getElementHeaderName()).isEmpty()) { clientException.setElements(response.getHeaders().get(exceptionType.getElementHeaderName())); } compositeException.addException(clientException); } } exceptionTypesInHeaders.removeAll(handledExceptions); if (!exceptionTypesInHeaders.isEmpty()) { LOG.error("Unmanaged exceptions: " + exceptionTypesInHeaders); } if (compositeException.hasExceptions()) { throw compositeException; } }
From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelectorPanel.java
private void deleteFromAssignmentsModel(AjaxRequestTarget target, MultipleAssignmentSelector from, MultipleAssignmentSelector to) { List<AssignmentEditorDto> fromProviderList = ((BaseSortableDataProvider) from.getProvider()) .getAvailableData();/* ww w .j ava 2s . co m*/ List<AssignmentEditorDto> listToBeRemoved = new ArrayList<>(); List<AssignmentEditorDto> assignmentsList = assignmentsModel.getObject(); for (AssignmentEditorDto dto : fromProviderList) { if (dto.isSelected()) { for (AssignmentEditorDto assignmentDto : assignmentsList) { String assignmentDtoOid = getAssignmentDtoOid(assignmentDto); String dtoOid = getAssignmentDtoOid(dto); if (assignmentDtoOid != null && dtoOid != null && assignmentDtoOid.equals(dtoOid) && areEqualReferenceObjects(assignmentDto.getTenantRef(), dto.getTenantRef()) && areEqualReferenceObjects(assignmentDto.getOrgRef(), dto.getOrgRef())) { if (assignmentDto.getStatus().equals(UserDtoStatus.ADD)) { listToBeRemoved.add(assignmentDto); } else { assignmentDto.setStatus(UserDtoStatus.DELETE); } } } dto.setSelected(false); } } assignmentsList.removeAll(listToBeRemoved); target.add(to); target.add(from); }
From source file:com.ibm.asset.trails.service.impl.ReconWorkspaceServiceImpl.java
@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED) public List<ReconcileType> reconcileTypes(boolean isManual) { //User Story 23223 - remove "CO/CM" from reconcile type list Start List<ReconcileType> reconcileTypeList = reconTypeDAO.reconcileTypes(isManual); if (isManual) { List<ReconcileType> reconcileTypeRemoveList = new ArrayList<ReconcileType>(); for (ReconcileType reconcileType : reconcileTypeList) { if (reconcileType.getId() != null && reconcileType.getId().intValue() == 2) {//judge if reconcile type is manual CO/CM reconcileTypeRemoveList.add(reconcileType);//add manual CO/CM reconcile type into reconcile type remove list }//from w w w . j av a 2 s .c o m } reconcileTypeList.removeAll(reconcileTypeRemoveList);//remove manual CO/CM reconcile type from reconcile type list } return reconcileTypeList; // User Story 23223 - remove "CO/CM" from reconcile type list End }
From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java
private void setupFieldPanels() { tabbed.removeAll();//from w ww . j av a2s.c om tabs.clear(); EntryType type = EntryTypes.getTypeOrDefault(entry.getType(), this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); // required fields List<String> requiredFields = addRequiredTab(type); // optional fields List<String> displayedOptionalFields = new ArrayList<>(); if ((type.getOptionalFields() != null) && !type.getOptionalFields().isEmpty()) { if (!frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) { addOptionalTab(type); } else { displayedOptionalFields.addAll(type.getPrimaryOptionalFields()); displayedOptionalFields.addAll(type.getSecondaryOptionalFields()); addOptionalTab(type); Set<String> deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet()); deprecatedFields.add(FieldName.YEAR); deprecatedFields.add(FieldName.MONTH); List<String> secondaryOptionalFields = type.getSecondaryOptionalFields(); List<String> optionalFieldsNotPrimaryOrDeprecated = new ArrayList<>(secondaryOptionalFields); optionalFieldsNotPrimaryOrDeprecated.removeAll(deprecatedFields); // Get list of all optional fields of this entry and their aliases Set<String> optionalFieldsAndAliases = new HashSet<>(); for (String field : type.getOptionalFields()) { optionalFieldsAndAliases.add(field); if (EntryConverter.FIELD_ALIASES_LTX_TO_TEX.containsKey(field)) { optionalFieldsAndAliases.add(EntryConverter.FIELD_ALIASES_LTX_TO_TEX.get(field)); } } // Get all optional fields which are deprecated Set<String> usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields); usedOptionalFieldsDeprecated.retainAll(optionalFieldsAndAliases); // Add tabs EntryEditorTab optPan2 = new EntryEditorTab(frame, panel, optionalFieldsNotPrimaryOrDeprecated, this, false, true, Localization.lang("Optional fields 2")); if (optPan2.fileListEditor != null) { fileListEditor = optPan2.fileListEditor; } tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan2.getPane(), Localization.lang("Show optional fields")); tabs.add(optPan2); if (!usedOptionalFieldsDeprecated.isEmpty()) { EntryEditorTab optPan3; optPan3 = new EntryEditorTab(frame, panel, new ArrayList<>(usedOptionalFieldsDeprecated), this, false, true, Localization.lang("Deprecated fields")); if (optPan3.fileListEditor != null) { fileListEditor = optPan3.fileListEditor; } tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan3.getPane(), Localization.lang("Show deprecated BibTeX fields")); tabs.add(optPan3); } } } // other fields List<String> displayedFields = Stream.concat(requiredFields.stream(), displayedOptionalFields.stream()) .map(String::toLowerCase).collect(Collectors.toList()); List<String> otherFields = entry.getFieldNames().stream().map(String::toLowerCase) .filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); otherFields.remove(BibEntry.KEY_FIELD); otherFields.removeAll(Globals.prefs.getCustomTabFieldNames()); if (!otherFields.isEmpty()) { addOtherTab(otherFields); } // general fields from preferences addGeneralTabs(); // source tab addSourceTab(); }
From source file:org.openmrs.module.metadatamapping.api.MetadataMappingServiceTest.java
@Test @Verifies(value = "respect includeRetired flag", method = "MetadataMappingService#getMetadataSources(boolean)") public void getMetadataSources_shouldRespectIncludeRetiredFlag() { // given/*w ww.j av a2s .co m*/ // data in the test data set // when MetadataSourceSearchCriteriaBuilder searchCriteriaBuilder = new MetadataSourceSearchCriteriaBuilder(); searchCriteriaBuilder.setIncludeAll(false); List<MetadataSource> nonRetiredSources = service.getMetadataSources(searchCriteriaBuilder.build()); searchCriteriaBuilder.setIncludeAll(true); List<MetadataSource> allSources = service.getMetadataSources(searchCriteriaBuilder.build()); // then Assert.assertEquals(2, nonRetiredSources.size()); for (MetadataSource metadataSource : nonRetiredSources) { Assert.assertFalse("metadata source " + metadataSource.getId() + " is not retired", metadataSource.isRetired()); } Assert.assertEquals(3, allSources.size()); allSources.removeAll(nonRetiredSources); Assert.assertEquals("after non-retired source have been removed, only retired sources remain", 1, allSources.size()); for (MetadataSource metadataSource : allSources) { Assert.assertTrue("metadata source " + metadataSource.getId() + " is retired", metadataSource.isRetired()); } }
From source file:de.tudarmstadt.ukp.clarin.webanno.monitoring.page.MonitoringPage.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public MonitoringPage() throws UIMAException, IOException, ClassNotFoundException { projectSelectionForm = new ProjectSelectionForm("projectSelectionForm"); monitoringDetailForm = new MonitoringDetailForm("monitoringDetailForm"); agreementForm = new AgreementForm("agreementForm", new Model<AnnotationLayer>(), new Model<Project>()); agreementForm.setVisible(false);/* www .j a v a2 s . c om*/ add(agreementForm); trainingResultForm = new TrainingResultForm("trainingResultForm"); trainingResultForm.setVisible(false); add(trainingResultForm); annotationTypeSelectionForm = new AnnotationTypeSelectionForm("annotationTypeSelectionForm"); annotationTypeSelectionForm.setVisible(false); add(annotationTypeSelectionForm); annotatorsProgressImage = new NonCachingImage("annotator"); annotatorsProgressImage.setOutputMarkupPlaceholderTag(true); annotatorsProgressImage.setVisible(false); annotatorsProgressPercentageImage = new NonCachingImage("annotatorPercentage"); annotatorsProgressPercentageImage.setOutputMarkupPlaceholderTag(true); annotatorsProgressPercentageImage.setVisible(false); overallProjectProgressImage = new NonCachingImage("overallProjectProgressImage"); final Map<String, Integer> overallProjectProgress = getOverallProjectProgress(); overallProjectProgressImage.setImageResource(createProgressChart(overallProjectProgress, 100, true)); overallProjectProgressImage.setOutputMarkupPlaceholderTag(true); overallProjectProgressImage.setVisible(true); add(overallProjectProgressImage); add(overview = new Label("overview", "overview of projects")); add(projectSelectionForm); projectName = new Label("projectName", ""); Project project = repository.listProjects().get(0); List<List<String>> userAnnotationDocumentLists = new ArrayList<List<String>>(); List<SourceDocument> dc = repository.listSourceDocuments(project); List<SourceDocument> trainingDoc = new ArrayList<SourceDocument>(); for (SourceDocument sdc : dc) { if (sdc.isTrainingDocument()) { trainingDoc.add(sdc); } } dc.removeAll(trainingDoc); for (int j = 0; j < repository.listProjectUsersWithPermissions(project).size(); j++) { List<String> userAnnotationDocument = new ArrayList<String>(); userAnnotationDocument.add(""); for (int i = 0; i < dc.size(); i++) { userAnnotationDocument.add(""); } userAnnotationDocumentLists.add(userAnnotationDocument); } List<String> documentListAsColumnHeader = new ArrayList<String>(); documentListAsColumnHeader.add("Users"); for (SourceDocument d : dc) { documentListAsColumnHeader.add(d.getName()); } TableDataProvider prov = new TableDataProvider(documentListAsColumnHeader, userAnnotationDocumentLists); List<IColumn<?, ?>> cols = new ArrayList<IColumn<?, ?>>(); for (int i = 0; i < prov.getColumnCount(); i++) { cols.add(new DocumentStatusColumnMetaData(prov, i, new Project(), repository)); } annotationDocumentStatusTable = new DefaultDataTable("rsTable", cols, prov, 2); monitoringDetailForm.setVisible(false); add(monitoringDetailForm.add(annotatorsProgressImage).add(annotatorsProgressPercentageImage) .add(projectName).add(annotationDocumentStatusTable)); annotationDocumentStatusTable.setVisible(false); }
From source file:de.tudarmstadt.ukp.clarin.webanno.monitoring.page.MonitoringPage.java
private Map<String, Integer> getPercentageOfFinishedDocumentsPerUser(Project aProject) { Map<String, Integer> annotatorsProgress = new HashMap<String, Integer>(); if (aProject != null) { for (User user : repository.listProjectUsersWithPermissions(aProject, PermissionLevel.USER)) { int finished = 0; int ignored = 0; int totalDocs = 0; List<SourceDocument> documents = repository.listSourceDocuments(aProject); List<SourceDocument> trainingDoc = new ArrayList<SourceDocument>(); for (SourceDocument sdc : documents) { if (sdc.isTrainingDocument()) { trainingDoc.add(sdc); }/*from w ww. j a v a 2 s . co m*/ } documents.removeAll(trainingDoc); for (SourceDocument document : documents) { totalDocs++; if (repository.isAnnotationFinished(document, user)) { finished++; } else if (repository.existsAnnotationDocument(document, user)) { AnnotationDocument annotationDocument = repository.getAnnotationDocument(document, user); if (annotationDocument.getState().equals(AnnotationDocumentState.IGNORE)) { ignored++; } } } annotatorsProgress.put(user.getUsername(), (int) Math.round((double) (finished * 100) / (totalDocs - ignored))); } } return annotatorsProgress; }
From source file:com.linkedin.helix.tools.ClusterSetup.java
public IdealState balanceIdealState(String clusterName, IdealState idealState) { // The new instances are added into the cluster already. So we need to find out the // instances that // already have partitions assigned to them. List<String> instanceNames = _admin.getInstancesInCluster(clusterName); Set<String> activeInstances = new HashSet<String>(); for (String partition : idealState.getPartitionSet()) { activeInstances.addAll(idealState.getRecord().getListField(partition)); }/*from ww w .j a va 2s. co m*/ instanceNames.removeAll(activeInstances); Map<String, Object> previousIdealState = buildInternalIdealState(idealState); Map<String, Object> balancedRecord = IdealStateCalculatorForStorageNode .calculateNextIdealState(instanceNames, previousIdealState); String[] states = parseStates(clusterName, idealState.getStateModelDefRef()); ZNRecord newIdealStateRecord = IdealStateCalculatorForStorageNode.convertToZNRecord(balancedRecord, idealState.getResourceName(), states[0], states[1]); Set<String> partitionSet = new HashSet<String>(); partitionSet.addAll(newIdealStateRecord.getMapFields().keySet()); partitionSet.addAll(newIdealStateRecord.getListFields().keySet()); Map<String, String> reversePartitionIndex = (Map<String, String>) balancedRecord .get("reversePartitionIndex"); for (String partition : partitionSet) { if (reversePartitionIndex.containsKey(partition)) { String originPartitionName = reversePartitionIndex.get(partition); if (partition.equals(originPartitionName)) { continue; } newIdealStateRecord.getMapFields().put(originPartitionName, newIdealStateRecord.getMapField(partition)); newIdealStateRecord.getMapFields().remove(partition); newIdealStateRecord.getListFields().put(originPartitionName, newIdealStateRecord.getListField(partition)); newIdealStateRecord.getListFields().remove(partition); } } newIdealStateRecord.getSimpleFields().putAll(idealState.getRecord().getSimpleFields()); return new IdealState(newIdealStateRecord); }
From source file:org.clothocad.phagebook.controllers.PersonController.java
@RequestMapping(value = "/listOrdersOfPerson", method = RequestMethod.GET) protected void listOrdersOfPerson(@RequestParam Map<String, String> params, HttpServletResponse response) throws ServletException, IOException { System.out.println("listing Orders"); Object pUser = params.get("user"); String user = pUser != null ? (String) pUser : ""; boolean isValid = false; if (!user.equals("")) { isValid = true;/*from www. j a v a2 s . co m*/ } if (isValid) { ClothoConnection conn = new ClothoConnection(Args.clothoLocation); Clotho clothoObject = new Clotho(conn); String username = this.backendPhagebookUser; String password = this.backendPhagebookPassword; Map loginMap = new HashMap(); loginMap.put("username", username); loginMap.put("credentials", password); clothoObject.login(loginMap); // able to query now. Person prashant = ClothoAdapter.getPerson(user, clothoObject); boolean exists = true; if (prashant.getId().equals("")) { System.out.println("Person does not exist in list open orders of person"); exists = false; } if (exists) { List<String> createdOrders = prashant.getCreatedOrders(); List<String> approvedOrderIds = prashant.getApprovedOrders(); List<String> deniedOrderIds = prashant.getDeniedOrders(); // removing overlap createdOrders.removeAll(deniedOrderIds); createdOrders.removeAll(approvedOrderIds); JSONArray allOrders = new JSONArray(); for (String created : createdOrders) { Order temp = ClothoAdapter.getOrder(created, clothoObject); JSONObject tempAsJSON = new JSONObject(); tempAsJSON.put("name", temp.getName()); tempAsJSON.put("description", temp.getDescription()); tempAsJSON.put("clothoId", temp.getId()); tempAsJSON.put("dateCreated", temp.getDateCreated().toString()); Person creator = ClothoAdapter.getPerson(temp.getCreatedById(), clothoObject); tempAsJSON.put("createdById", creator.getEmailId()); tempAsJSON.put("createdByName", creator.getFirstName() + " " + creator.getLastName()); tempAsJSON.put("products", temp.getProducts()); tempAsJSON.put("orderLimit", temp.getMaxOrderSize()); tempAsJSON.put("taxRate", temp.getTaxRate()); tempAsJSON.put("budget", temp.getBudget()); if (!temp.getApprovedById().equals("") && !temp.getApprovedById().equals("Not Set")) { tempAsJSON.put("approvedById", (ClothoAdapter.getPerson(temp.getApprovedById(), clothoObject)).getEmailId()); } JSONArray receivedByIds = new JSONArray(); List<String> receivedBys = temp.getReceivedByIds(); for (int i = 0; i < receivedBys.size(); i++) { if (!receivedBys.get(i).equals("") && !receivedBys.get(i).equals("Not Set")) { JSONObject receivedByJSON = new JSONObject(); receivedByJSON.put("" + i, (ClothoAdapter.getPerson(receivedBys.get(i), clothoObject)).getEmailId()); receivedByIds.put(receivedByJSON); } } tempAsJSON.put("receivedByIds", receivedByIds); tempAsJSON.put("relatedProjectName", (ClothoAdapter.getProject(temp.getRelatedProjectId(), clothoObject)).getName()); tempAsJSON.put("status", temp.getStatus()); tempAsJSON.put("affiliatedLabId", temp.getAffiliatedLabId()); allOrders.put(tempAsJSON); // put it in there... } for (String approved : approvedOrderIds) { System.out.println("APPROVED ID: " + approved); Order approvedOrder = ClothoAdapter.getOrder(approved, clothoObject); JSONObject approvedJSON = new JSONObject(); approvedJSON.put("name", approvedOrder.getName()); approvedJSON.put("dateApproved", approvedOrder.getDateApproved()); approvedJSON.put("description", approvedOrder.getDescription()); approvedJSON.put("clothoId", approvedOrder.getId()); approvedJSON.put("dateCreated", approvedOrder.getDateCreated().toString()); Person creator = ClothoAdapter.getPerson(approvedOrder.getCreatedById(), clothoObject); approvedJSON.put("createdById", creator.getEmailId()); approvedJSON.put("createdByName", creator.getFirstName() + " " + creator.getLastName()); approvedJSON.put("products", approvedOrder.getProducts()); approvedJSON.put("orderLimit", approvedOrder.getMaxOrderSize()); approvedJSON.put("taxRate", approvedOrder.getTaxRate()); approvedJSON.put("budget", approvedOrder.getBudget()); System.out.println(approvedOrder.getApprovedById()); if (!approvedOrder.getApprovedById().equals("") && !approvedOrder.getApprovedById().equals("Not Set")) { approvedJSON.put("approvedById", (ClothoAdapter.getPerson(approvedOrder.getApprovedById(), clothoObject)) .getEmailId()); } JSONArray receivedByIds = new JSONArray(); List<String> receivedBys = approvedOrder.getReceivedByIds(); System.out.println(""); System.out.println(""); System.out.println(receivedBys); System.out.println(""); System.out.println(""); //questionably secure if statement if (receivedBys.isEmpty()) { JSONObject receivedByJSON = new JSONObject(); receivedByJSON.put("" + 0, creator.getEmailId()); receivedByIds.put(receivedByJSON); System.out.println("empty:" + creator.getEmailId()); } else { for (int i = 0; i < receivedBys.size(); i++) { if (!receivedBys.get(i).equals("") && !receivedBys.get(i).equals("Not Set")) { JSONObject receivedByJSON = new JSONObject(); receivedByJSON.put("" + i, (ClothoAdapter.getPerson(receivedBys.get(i), clothoObject)).getEmailId()); receivedByIds.put(receivedByJSON); } } } //questionably secure if statement approvedJSON.put("receivedByIds", receivedByIds); approvedJSON.put("relatedProjectName", (ClothoAdapter.getProject(approvedOrder.getRelatedProjectId(), clothoObject)) .getName()); approvedJSON.put("status", approvedOrder.getStatus()); approvedJSON.put("affiliatedLabId", approvedOrder.getAffiliatedLabId()); allOrders.put(approvedJSON); } for (String denied : deniedOrderIds) { Order deniedOrder = ClothoAdapter.getOrder(denied, clothoObject); JSONObject deniedJSON = new JSONObject(); deniedJSON.put("name", deniedOrder.getName()); deniedJSON.put("description", deniedOrder.getDescription()); deniedJSON.put("clothoId", deniedOrder.getId()); deniedJSON.put("dateCreated", deniedOrder.getDateCreated().toString()); Person creator = ClothoAdapter.getPerson(deniedOrder.getCreatedById(), clothoObject); deniedJSON.put("createdById", creator.getEmailId()); deniedJSON.put("createdByName", creator.getFirstName() + " " + creator.getLastName()); deniedJSON.put("products", deniedOrder.getProducts()); deniedJSON.put("orderLimit", deniedOrder.getMaxOrderSize()); deniedJSON.put("taxRate", deniedOrder.getTaxRate()); deniedJSON.put("budget", deniedOrder.getBudget()); if (!deniedOrder.getApprovedById().equals("") && !deniedOrder.getApprovedById().equals("Not Set")) { deniedJSON.put("approvedById", (ClothoAdapter.getPerson(deniedOrder.getApprovedById(), clothoObject)) .getEmailId()); } JSONArray receivedByIds = new JSONArray(); List<String> receivedBys = deniedOrder.getReceivedByIds(); for (int i = 0; i < receivedBys.size(); i++) { if (!receivedBys.get(i).equals("") && !receivedBys.get(i).equals("Not Set")) { JSONObject receivedByJSON = new JSONObject(); receivedByJSON.put("" + i, (ClothoAdapter.getPerson(receivedBys.get(i), clothoObject)).getEmailId()); receivedByIds.put(receivedByJSON); } } deniedJSON.put("receivedByIds", receivedByIds); deniedJSON.put("relatedProjectName", (ClothoAdapter.getProject(deniedOrder.getRelatedProjectId(), clothoObject)).getName()); deniedJSON.put("status", deniedOrder.getStatus()); deniedJSON.put("affiliatedLabId", deniedOrder.getAffiliatedLabId()); allOrders.put(deniedJSON); } response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_OK); PrintWriter out = response.getWriter(); out.print(allOrders); out.flush(); } else { response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); JSONObject responseJSON = new JSONObject(); responseJSON.put("message", "id provided does not exist"); PrintWriter out = response.getWriter(); out.print(responseJSON); out.flush(); } conn.closeConnection(); } else { response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); JSONObject responseJSON = new JSONObject(); responseJSON.put("message", "missing an id to query with"); PrintWriter out = response.getWriter(); out.print(responseJSON); out.flush(); } }
From source file:com.bdaum.zoom.gps.internal.operations.GeotagOperation.java
private boolean geoname(final Asset asset, final Meta meta, final int resumed, final int i, IProgressMonitor aMonitor, IAdaptable info) throws UnknownHostException, EOFException { double latitude = asset.getGPSLatitude(); double longitude = asset.getGPSLongitude(); if (!Double.isNaN(latitude) && !Double.isNaN(longitude)) { LocationImpl location = null;/*from w w w. j av a2s . c o m*/ List<String> oldKeywords = new ArrayList<String>(); LocationCreatedImpl rel = null; String assetId = asset.getStringId(); for (LocationCreatedImpl locationCreated : dbManager.obtainStructForAsset(LocationCreatedImpl.class, assetId, true)) { rel = locationCreated; LocationImpl obj = dbManager.obtainById(LocationImpl.class, rel.getLocation()); if (obj != null) Utilities.extractKeywords(location = obj, oldKeywords); } List<String> keepKeywords = new ArrayList<String>(); for (LocationShownImpl locationShown : dbManager.obtainStructForAsset(LocationShownImpl.class, assetId, false)) { LocationImpl obj = dbManager.obtainById(LocationImpl.class, locationShown.getLocation()); if (obj != null) Utilities.extractKeywords(obj, keepKeywords); } oldKeywords.removeAll(keepKeywords); final LocationImpl loc = location; final List<String> ok = oldKeywords; final LocationCreatedImpl created = rel; if (location == null || GpsUtilities.isEmpty(location) || gpsConfiguration.overwrite) { Waypoint wp = getPlaceInfo(meta, i, latitude, longitude, aMonitor, info); if (wp != null) { if (i >= resumed) createBackup(asset, i - resumed, true); final LocationImpl newLocation = new LocationImpl(); GpsUtilities.transferPlacedata(wp, newLocation); return storeSafely(() -> assignGeoNames(asset, meta, i >= resumed ? backups[i - resumed] : null, loc, ok, created, newLocation), 1); } } } aMonitor.worked(1); return false; }