List of usage examples for java.util HashSet toArray
Object[] toArray();
From source file:no.abmu.organisationregister.service.hibernate3.OrganisationUnitServiceH3Impl.java
public OrganisationUnit[] getOrganisationUnitWithChildren(Long parentOrganisationId) { OrganisationUnit parent = get(parentOrganisationId); HashSet set = new HashSet(); insertChildren(set, parent);//w w w . j a v a 2 s .c o m Object[] arr = set.toArray(); return (OrganisationUnit[]) Arrays.asList(arr).toArray(new OrganisationUnit[arr.length]); }
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;/* www . j a v a 2 s . c o m*/ // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:org.lockss.devtools.plugindef.EditableDefinablePlugin.java
public void setPluginConfigDescrs(HashSet descrs) { logger.info("Setting the plugin configuration parameters"); if (logger.isDebug()) { logger.debug("Setting the plugin configuration parameters in detail"); Iterator iter = descrs.iterator(); for (int ix = 1; iter.hasNext(); ++ix) { logger.debug("Plugin configuration parameter " + ix + ": " + ((ConfigParamDescr) iter.next()).toDetailedString()); }/*from w w w .java 2 s . c o m*/ } List descrlist = ListUtil.fromArray(descrs.toArray()); definitionMap.putCollection(DefinablePlugin.KEY_PLUGIN_CONFIG_PROPS, descrlist); }
From source file:edu.isi.pfindr.servlets.QueryServlet.java
/** * bookmark a query//from www. java2 s . co m * * @param request * the servlet request * @param conn * the DB connection * @return the bookmark */ private JSONObject studyMetadata(HttpServletRequest request, Connection conn) throws ServletException { JSONObject res = new JSONObject(); try { String sqlQuery = "select distinct sex from " + Utils.STUDIES_TABLE + " order by sex"; PreparedStatement stmt = conn.prepareStatement(sqlQuery); JSONArray rows = Utils.executeSQL(stmt); //System.out.println(rows); JSONArray gender = new JSONArray(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { gender.put(row.getString(0)); } } stmt.close(); res.put("gender", gender); sqlQuery = "select distinct race from " + Utils.STUDIES_TABLE + " order by race"; stmt = conn.prepareStatement(sqlQuery); rows = Utils.executeSQL(stmt); HashSet<String> raceSet = new HashSet<String>(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { String values = row.getString(0); StringTokenizer tokenizer = new StringTokenizer(values, ","); while (tokenizer.hasMoreTokens()) { raceSet.add(tokenizer.nextToken().trim()); } } } Object raceValues[] = raceSet.toArray(); Utils.sortArray(raceValues); JSONArray races = new JSONArray(); for (int i = 0; i < raceValues.length; i++) { races.put(raceValues[i]); } stmt.close(); res.put("races", races); sqlQuery = "select distinct platform from " + Utils.STUDIES_TABLE + " order by platform"; stmt = conn.prepareStatement(sqlQuery); rows = Utils.executeSQL(stmt); HashSet<String> platformSet = new HashSet<String>(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { String values = row.getString(0); StringTokenizer tokenizer = new StringTokenizer(values, "|"); while (tokenizer.hasMoreTokens()) { platformSet.add(tokenizer.nextToken().trim()); } } } Object platformValues[] = platformSet.toArray(); Utils.sortArray(platformValues); JSONArray platform = new JSONArray(); for (int i = 0; i < platformValues.length; i++) { platform.put(platformValues[i]); } stmt.close(); res.put("platform", platform); sqlQuery = "select distinct study_type from " + Utils.STUDIES_TABLE + " order by study_type"; stmt = conn.prepareStatement(sqlQuery); rows = Utils.executeSQL(stmt); HashSet<String> study_typeSet = new HashSet<String>(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { String values = row.getString(0); StringTokenizer tokenizer = new StringTokenizer(values, ","); while (tokenizer.hasMoreTokens()) { study_typeSet.add(tokenizer.nextToken().trim()); } } } Object study_typeValues[] = study_typeSet.toArray(); Utils.sortArray(study_typeValues); JSONArray study_type = new JSONArray(); for (int i = 0; i < study_typeValues.length; i++) { study_type.put(study_typeValues[i]); } stmt.close(); res.put("study_type", study_type); sqlQuery = "select distinct genetic_type from " + Utils.STUDIES_TABLE + " order by genetic_type"; stmt = conn.prepareStatement(sqlQuery); rows = Utils.executeSQL(stmt); HashSet<String> genetic_typeSet = new HashSet<String>(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { String values = row.getString(0); StringTokenizer tokenizer = new StringTokenizer(values, ","); while (tokenizer.hasMoreTokens()) { genetic_typeSet.add(tokenizer.nextToken().trim()); } } } Object genetic_typeValues[] = genetic_typeSet.toArray(); Utils.sortArray(genetic_typeValues); JSONArray genetic_type = new JSONArray(); for (int i = 0; i < genetic_typeValues.length; i++) { genetic_type.put(genetic_typeValues[i]); } stmt.close(); res.put("genetic_type", genetic_type); sqlQuery = "select distinct(unnest (a.da)) b from (SELECT diseases, regexp_split_to_array(diseases, ';') as da FROM " + Utils.STUDIES_TABLE + ") a order by b"; stmt = conn.prepareStatement(sqlQuery); rows = Utils.executeSQL(stmt); HashSet<String> diseasesSet = new HashSet<String>(); for (int i = 0; i < rows.length(); i++) { JSONArray row = rows.getJSONArray(i); if (!row.isNull(0)) { String values = row.getString(0); diseasesSet.add(values.trim()); } } Object diseasesValues[] = diseasesSet.toArray(); Utils.sortArray(diseasesValues); JSONArray diseases = new JSONArray(); for (int i = 0; i < diseasesValues.length; i++) { diseases.put(diseasesValues[i]); } stmt.close(); res.put("diseases", diseases); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new ServletException(e.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return res; }
From source file:edu.cens.loci.provider.LociDbUtils.java
public ArrayList<String> getSavedKeywords() { Cursor cursor = getPlaceData(Keyword.CONTENT_ITEM_TYPE); HashSet<String> keywordSet = new HashSet<String>(); if (cursor.moveToFirst()) { do {// w w w . ja v a2 s .c o m String keyword = cursor.getString(cursor.getColumnIndex(Keyword.TAG)); if (!keywordSet.contains(keyword)) { keywordSet.add(keyword); } } while (cursor.moveToNext()); } cursor.close(); Object[] keywordObjArray = keywordSet.toArray(); ArrayList<String> keywordArray = new ArrayList<String>(); for (Object keywordObj : keywordObjArray) { keywordArray.add((String) keywordObj); } Collections.sort(keywordArray); return keywordArray; }
From source file:com.pari.reports.request.handlers.ManageExportHandlerImpl.java
private HashSet<Object> getMembers(LWObjectGroup group) { HashSet<Object> deviceIds = new HashSet<Object>(); if (group.getMemberIds() != null && group.getMemberIds().length > 0) { deviceIds.addAll(Arrays.asList(group.getMemberIds())); }/*from ww w .j a v a2 s .c o m*/ if (group.getChildren() != null) { for (LWObjectGroup child : group.getChildren()) { deviceIds.addAll(getMembers(child)); } } if (getRequestDetails().getReportId().equals("manage_interface_groups")) { return deviceIds; } return getGroupMembers(deviceIds.toArray()); }
From source file:edu.ku.brc.specify.conversion.AgentConverter.java
protected void parseAndFixMultiLineAddresses() { String whereStr = " FROM address a WHERE Address like '%\r\n%'"; String sql = "SELECT COUNT(*)" + whereStr; if (BasicSQLUtils.getCountAsInt(sql) < 1) { return;//from ww w .j ava 2 s . c o m } sql = "SELECT AddressID, Address" + whereStr; Statement stmt = null; //PreparedStatement pStmt = null; try { // pStmt = newDBConn.prepareStatement("UPDATE address SET Address=?, Address2=?, City=?, State=?, PostalCode=? WHERE AddressID = ?"); stmt = newDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery(sql); HashSet<Integer> hashSet = new HashSet<Integer>(); while (rs.next()) { String[] toks = StringUtils.split(rs.getString(2), "\r\n"); hashSet.add(toks.length); } rs.close(); for (Integer i : (Integer[]) hashSet.toArray()) { System.out.println(i); } System.out.println(); } catch (Exception ex) { } }
From source file:ddf.test.itests.catalog.TestFederation.java
private Set<String> getEvents(String subscriptionId) { HashSet<String> foundIds = new HashSet<String>(); List<Call> calls = new ArrayList<>(server.getCalls()); if (CollectionUtils.isNotEmpty(calls)) { for (Call call : calls) { if (call.getMethod().matchesMethod(Method.POST.name()) && StringUtils.isNotEmpty(call.getPostBody())) { LOGGER.debug("Event received '{}'", call.getPostBody()); XmlPath xmlPath = new XmlPath(call.getPostBody()); String id;/*from w w w . j a v a 2 s .com*/ try { String foundSubscriptionId = xmlPath.get("GetRecordsResponse.RequestId"); if (StringUtils.isNotBlank(foundSubscriptionId) && subscriptionId.equals(foundSubscriptionId)) { id = xmlPath.get("GetRecordsResponse.SearchResults.Record.identifier"); if (StringUtils.isNotEmpty(id)) { foundIds.add(StringUtils.trim(id)); } } else { LOGGER.info("event for id {} not found.", subscriptionId); } } catch (ClassCastException e) { // not necessarily a problem that an particular path (event) wasn't found LOGGER.info("Unable to evaluate path for event {}", subscriptionId); } } } LOGGER.debug("Id {}, Event Found Ids: {}", subscriptionId, Arrays.toString(foundIds.toArray())); } return foundIds; }
From source file:org.tellervo.desktop.bulkdataentry.command.ImportSelectedSamplesCommand.java
/** * @see com.dmurph.mvc.control.ICommand#execute(com.dmurph.mvc.MVCEvent) */// w w w. ja v a 2s.com @Override public void execute(MVCEvent argEvent) { BulkImportModel model = BulkImportModel.getInstance(); SampleModel smodel = model.getSampleModel(); SampleTableModel tmodel = smodel.getTableModel(); ElementModel emodel = model.getElementModel(); MVCArrayList<TridasElement> elementlist = emodel.getImportedList(); ElementTableModel etablemodel = emodel.getTableModel(); ArrayList<IBulkImportSingleRowModel> selected = new ArrayList<IBulkImportSingleRowModel>(); tmodel.getSelected(selected); // here is where we verify they contain required info HashSet<String> requiredMessages = new HashSet<String>(); ArrayList<SingleSampleModel> incompleteModels = new ArrayList<SingleSampleModel>(); HashSet<String> definedProps = new HashSet<String>(); for (IBulkImportSingleRowModel srm : selected) { SingleSampleModel som = (SingleSampleModel) srm; definedProps.clear(); for (String s : SingleSampleModel.TABLE_PROPERTIES) { if (som.getProperty(s) != null) { definedProps.add(s); } } if (smodel.isRadiusWithSample()) { for (String s : SingleRadiusModel.PROPERTIES) { if (som.getRadiusModel().getProperty(s) != null) { definedProps.add(s); } } } boolean incomplete = false; // object if (!definedProps.contains(SingleSampleModel.OBJECT)) { requiredMessages.add("Cannot import without a parent object."); incomplete = true; } // element if (!definedProps.contains(SingleSampleModel.ELEMENT)) { requiredMessages.add("Cannot import without a parent element."); incomplete = true; } else if (fixTempParentCodes(som, emodel)) { // There was a temp code but it is fixed now } else { requiredMessages.add("Cannot import as parent element has not been created yet"); incomplete = true; } // type if (!definedProps.contains(SingleSampleModel.TYPE)) { requiredMessages.add("Sample must contain a type."); incomplete = true; } // title if (!definedProps.contains(SingleSampleModel.TITLE)) { requiredMessages.add("Sample must have a title."); incomplete = true; } if (smodel.isRadiusWithSample()) { if (!definedProps.contains(SingleRadiusModel.TITLE)) { requiredMessages.add("Radius title must be populated."); incomplete = true; } } if (incomplete) { incompleteModels.add(som); } } if (!incompleteModels.isEmpty()) { StringBuilder message = new StringBuilder(); message.append("Please correct the following errors:\n"); message.append(StringUtils.join(requiredMessages.toArray(), "\n")); Alert.message(model.getMainView(), "Importing Errors", message.toString()); return; } // now we actually create the models int i = 0; for (IBulkImportSingleRowModel srm : selected) { SingleSampleModel ssm = (SingleSampleModel) srm; TridasSample origSample = new TridasSample(); if (!ssm.isDirty()) { System.out.println("Object isn't dirty, not saving/updating: " + ssm.getProperty(SingleSampleModel.TITLE).toString()); } ssm.populateToTridasSample(origSample); Object e = ssm.getProperty(SingleSampleModel.ELEMENT); TridasElement parentElement = null; if (e instanceof TridasElementOrPlaceholder) { parentElement = ((TridasElementOrPlaceholder) e).getTridasElement(); } else if (e instanceof TridasElement) { parentElement = (TridasElement) e; } // sample first EntityResource<TridasSample> sampleResource; if (origSample.getIdentifier() != null) { sampleResource = new EntityResource<TridasSample>(origSample, TellervoRequestType.UPDATE, TridasSample.class); } else { sampleResource = new EntityResource<TridasSample>(origSample, parentElement, TridasSample.class); } sampleResource.setProperty(TellervoResourceProperties.ENTITY_REQUEST_FORMAT, TellervoRequestFormat.SUMMARY); // set up a dialog... Window parentWindow = SwingUtilities.getWindowAncestor(model.getMainView()); TellervoResourceAccessDialog dialog = new TellervoResourceAccessDialog(parentWindow, sampleResource, i, selected.size()); sampleResource.query(); dialog.setVisible(true); if (!dialog.isSuccessful()) { JOptionPane.showMessageDialog(BulkImportModel.getInstance().getMainView(), I18n.getText("error.savingChanges") + "\r\n" + I18n.getText("error") + ": " + dialog.getFailException().getLocalizedMessage(), I18n.getText("error"), JOptionPane.ERROR_MESSAGE); continue; } ssm.populateFromTridasSample(sampleResource.getAssociatedResult()); ssm.setDirty(false); tmodel.setSelected(ssm, false); // add to imported list or update existing if (origSample.getIdentifier() != null) { TridasSample found = null; for (TridasSample tox : model.getSampleModel().getImportedList()) { if (tox.getIdentifier().getValue().equals(origSample.getIdentifier().getValue())) { found = tox; break; } } if (found == null) { //Alert.error("Error updating model", "Couldn't find the object in the model to update, please report bug."); } else { sampleResource.getAssociatedResult().copyTo(found); } } else { model.getSampleModel().getImportedList().add(sampleResource.getAssociatedResult()); } if (ssm.getRadiusModel() != null) { // now lets do the radius TridasRadius origRadius = new TridasRadius(); ssm.getRadiusModel().populateToTridasRadius(origRadius); TridasSample parentSample = sampleResource.getAssociatedResult(); // sample first EntityResource<TridasRadius> radiusResource; if (origRadius.getIdentifier() != null) { radiusResource = new EntityResource<TridasRadius>(origRadius, TellervoRequestType.UPDATE, TridasRadius.class); } else { radiusResource = new EntityResource<TridasRadius>(origRadius, parentSample, TridasRadius.class); } // set up a dialog... parentWindow = SwingUtilities.getWindowAncestor(model.getMainView()); dialog = TellervoResourceAccessDialog.forWindow(parentWindow, radiusResource); radiusResource.query(); dialog.setVisible(true); if (!dialog.isSuccessful()) { JOptionPane.showMessageDialog(BulkImportModel.getInstance().getMainView(), I18n.getText("error.savingChanges") + "\r\n" + I18n.getText("error") + ": " + dialog.getFailException().getLocalizedMessage(), I18n.getText("error"), JOptionPane.ERROR_MESSAGE); continue; } ssm.getRadiusModel().populateFromTridasRadius(radiusResource.getAssociatedResult()); ssm.getRadiusModel().setDirty(false); tmodel.setSelected(ssm, false); } i++; } }
From source file:org.openanzo.datasource.nodecentric.internal.NodeCentricDatasource.java
private boolean checkIfTablesExists(Connection connection, boolean none) throws AnzoException { ResultSet rs = null;/*from www . j ava 2 s . c o m*/ try { long currentVersion = none ? SCHEMA_VERSION : getCurrentVersion(connection); boolean tables = true; boolean sequences = false; boolean views = false; try { rs = connection.getMetaData().getTableTypes(); while (rs.next() && (!tables || !sequences || !views)) { String type = rs.getString(1); if (type.toUpperCase().equals(table)) { tables = true; } else if (type.toUpperCase().equals(seq)) { sequences = true; } else if (type.toUpperCase().equals(view)) { views = true; } } } finally { if (rs != null) { rs.close(); } } if (tables) { try { rs = connection.getMetaData().getTables(null, null, null, new String[] { table }); HashSet<String> requiredTables = new HashSet<String>(); requiredTables.add(serverUpper); java.util.Collections.addAll(requiredTables, resetService.getRequiredTables()); java.util.Collections.addAll(requiredTables, resetService.getNodeCentricTables()); while (rs.next()) { String tbl = rs.getString(3); if (requiredTables.remove(tbl.toUpperCase()) && none) { throw new AnzoException(ExceptionConstants.RDB.INCOMPLETE_DATABASE); } if (tbl.toUpperCase().equals("ANZO_U")) { ResultSet metadata = connection.getMetaData().getColumns(null, null, tbl, null); while (metadata.next()) { String name = metadata.getString(4); if (name.toUpperCase().equals("VALUE")) { int size = metadata.getInt(7); configuration.setMaxLongObjectLength(size); nodeLayout.setMaxLength(size); break; } } } } if (!none && requiredTables.size() > 0) { throw new AnzoException(ExceptionConstants.RDB.FAILED_GETTING_TABLE_STATUS, Arrays.toString(requiredTables.toArray())); } } finally { if (rs != null) { rs.close(); } } } if (sequences) { String seqs[][] = resetService.getRequiredSequences(); for (int i = 0; i < currentVersion; i++) { String vseq[] = seqs[i]; if (vseq != null && vseq.length > 0) { try { rs = connection.getMetaData().getTables(null, null, null, new String[] { seq }); HashSet<String> requiredSeq = new HashSet<String>(); java.util.Collections.addAll(requiredSeq, vseq); while (rs.next()) { String tbl = rs.getString(3); if (requiredSeq.remove(tbl.toUpperCase()) && none) { throw new AnzoException(ExceptionConstants.RDB.INCOMPLETE_DATABASE); } } if (!none && requiredSeq.size() > 0) { throw new AnzoException(ExceptionConstants.RDB.FAILED_GETTING_TABLE_STATUS, Arrays.toString(requiredSeq.toArray())); } } finally { if (rs != null) { rs.close(); } } } } } if (views) { try { rs = connection.getMetaData().getTables(null, null, null, new String[] { view }); HashSet<String> required = new HashSet<String>(); if (currentVersion < 12) { required.add("ALL_STMTS_VIEW"); } else { java.util.Collections.addAll(required, resetService.getRequiredViews()); } while (rs.next()) { String tbl = rs.getString(3); if (required.remove(tbl.toUpperCase()) && none) { throw new AnzoException(ExceptionConstants.RDB.INCOMPLETE_DATABASE); } } if (!none && required.size() > 0) { throw new AnzoException(ExceptionConstants.RDB.FAILED_GETTING_TABLE_STATUS, Arrays.toString(required.toArray())); } } finally { if (rs != null) { rs.close(); } } } } catch (SQLException e) { log.error(LogUtils.RDB_MARKER, "Error checking if statements exist", e); throw new AnzoException(ExceptionConstants.RDB.FAILED_INITIALZE_DB, e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { log.debug(LogUtils.RDB_MARKER, "Error closing result set", e); } } } return true; }