List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:edu.ucla.stat.SOCR.analyses.gui.PrincipalComponentAnalysis.java
/**This method defines the specific statistical Analysis to be carried our on the user specified data. ANOVA is done in this case. */ public void doAnalysis() { if (dataTable.isEditing()) dataTable.getCellEditor().stopCellEditing(); if (!hasExample) { JOptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE); return;//from w w w . j ava2 s.co m } Data data = new Data(); String firstMessage = "Would you like to use all the data columns in this Principal Components Analysis?"; String title = "SOCR - Principal Components Analysis"; String secondMessage = "Please enter the column numbers (seperated by comma) that you would like to use."; String columnNumbers = ""; int reply = JOptionPane.showConfirmDialog(null, firstMessage, title, JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { String cellValue = null; int originalRow = 0; for (int k = 0; k < dataTable.getRowCount(); k++) { cellValue = ((String) dataTable.getValueAt(k, 0)); if (cellValue != null && !cellValue.equals("")) { originalRow++; } } cellValue = null; int originalColumn = 0; for (int k = 0; k < dataTable.getColumnCount(); k++) { cellValue = ((String) dataTable.getValueAt(0, k)); if (cellValue != null && !cellValue.equals("")) { originalColumn++; } } dataRow = originalRow; dataColumn = originalColumn; String PCA_Data1[][] = new String[originalRow][originalColumn]; double PCA_Data[][] = new double[originalRow][originalColumn]; for (int k = 0; k < originalRow; k++) for (int j = 0; j < originalColumn; j++) { if (dataTable.getValueAt(k, j) != null && !dataTable.getValueAt(k, j).equals("")) { PCA_Data1[k][j] = (String) dataTable.getValueAt(k, j); PCA_Data[k][j] = Double.parseDouble(PCA_Data1[k][j]); } } double PCA_Adjusted_Data[][] = new double[originalRow][originalColumn]; double column_Total = 0; double column_Mean = 0; for (int j = 0; j < originalColumn; j++) for (int k = 0; k < originalRow; k++) { column_Total += PCA_Data[k][j]; if (k == (originalRow - 1)) { column_Mean = column_Total / originalRow; for (int p = 0; p < originalRow; p++) { PCA_Adjusted_Data[p][j] = PCA_Data[p][j] - column_Mean; } column_Total = 0; column_Mean = 0; } } Covariance cov = new Covariance(PCA_Adjusted_Data); RealMatrix matrix = cov.getCovarianceMatrix(); EigenDecomposition eigenDecomp = new EigenDecomposition(matrix, 0); storedData = eigenDecomp; RealMatrix eigenvectorMatrix = eigenDecomp.getV(); EValueArray = eigenDecomp.getRealEigenvalues(); eigenvectorMatrix = eigenvectorMatrix.transpose(); double eigenvectorArray[][] = eigenvectorMatrix.getData(); /*for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) { System.out.println(eigenvectorArray[j][k] + " "); } */ Matrix matrix1 = new Matrix(eigenvectorArray); Matrix matrix2 = new Matrix(PCA_Adjusted_Data); matrix2 = matrix2.transpose(); Matrix finalProduct = matrix1.times(matrix2); finalProduct = finalProduct.transpose(); double finalArray[][] = finalProduct.getArrayCopy(); for (int j = 0; j < originalRow; j++) for (int k = 0; k < originalColumn; k++) { PCATable.setValueAt(finalArray[j][k], j, k); } xData = new double[originalRow]; yData = new double[originalRow]; for (int i = 0; i < originalRow; i++) { xData[i] = finalArray[i][0]; } for (int i = 0; i < originalRow; i++) { yData[i] = finalArray[i][1]; } dependentHeader = "C1"; independentHeader = "C2"; } else { // start here try { columnNumbers = JOptionPane.showInputDialog(secondMessage); } catch (Exception e) { } String columnNumbersFinal = "," + columnNumbers.replaceAll("\\s", "") + ","; Vector<Integer> locationOfComma = new Vector<Integer>(100); for (int i = 0; i < columnNumbersFinal.length(); i++) { char d = columnNumbersFinal.charAt(i); if (d == ',') locationOfComma.add(i); } Vector<Integer> vector = new Vector<Integer>(100); // vector containing column selected numbers for (int i = 0; i < locationOfComma.size() - 1; i++) { String temp = columnNumbersFinal.substring(locationOfComma.get(i) + 1, locationOfComma.get(i + 1)); if (temp == "") continue; vector.add((Integer.parseInt(temp) - 1)); } dependentHeader = "C" + (vector.get(0) + 1); independentHeader = "C" + (vector.get(1) + 1); // System.out.println("Vector size is: " + vector.size() + "\n"); String cellValue = null; int originalRow = 0; for (int k = 0; k < dataTable.getRowCount(); k++) { cellValue = ((String) dataTable.getValueAt(k, 0)); if (cellValue != null && !cellValue.equals("")) { originalRow++; } } int originalColumn = vector.size(); dataRow = originalRow; dataColumn = originalColumn; String PCA_Data1[][] = new String[originalRow][originalColumn]; double PCA_Data[][] = new double[originalRow][originalColumn]; for (int k = 0; k < originalRow; k++) for (int j = 0; j < originalColumn; j++) { if (dataTable.getValueAt(k, vector.get(j)) != null && !dataTable.getValueAt(k, vector.get(j)).equals("")) { PCA_Data1[k][j] = (String) dataTable.getValueAt(k, vector.get(j)); PCA_Data[k][j] = Double.parseDouble(PCA_Data1[k][j]); } } double PCA_Adjusted_Data[][] = new double[originalRow][originalColumn]; double column_Total = 0; double column_Mean = 0; for (int j = 0; j < originalColumn; j++) for (int k = 0; k < originalRow; k++) { column_Total += PCA_Data[k][j]; if (k == (originalRow - 1)) { column_Mean = column_Total / originalRow; for (int p = 0; p < originalRow; p++) { PCA_Adjusted_Data[p][j] = PCA_Data[p][j] - column_Mean; } column_Total = 0; column_Mean = 0; } } Covariance cov = new Covariance(PCA_Adjusted_Data); RealMatrix matrix = cov.getCovarianceMatrix(); EigenDecomposition eigenDecomp = new EigenDecomposition(matrix, 0); storedData = eigenDecomp; RealMatrix eigenvectorMatrix = eigenDecomp.getV(); EValueArray = eigenDecomp.getRealEigenvalues(); // added eigenvectorMatrix = eigenvectorMatrix.transpose(); double eigenvectorArray[][] = eigenvectorMatrix.getData(); /*for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) { System.out.println(eigenvectorArray[j][k] + " "); } */ Matrix matrix1 = new Matrix(eigenvectorArray); Matrix matrix2 = new Matrix(PCA_Adjusted_Data); matrix2 = matrix2.transpose(); Matrix finalProduct = matrix1.times(matrix2); finalProduct = finalProduct.transpose(); double finalArray[][] = finalProduct.getArrayCopy(); /* for (int j = 0; j < dataTable.getColumnCount(); j++) for (int k = 0; k < dataTable.getRowCount(); k++) { System.out.println(finalArray[j][k] + " "); }*/ for (int j = 0; j < originalRow; j++) for (int k = 0; k < originalColumn; k++) { PCATable.setValueAt(finalArray[j][k], j, k); } xData = new double[originalRow]; yData = new double[originalRow]; for (int i = 0; i < originalRow; i++) { xData[i] = finalArray[i][0]; } for (int i = 0; i < originalRow; i++) { yData[i] = finalArray[i][1]; } } map = new HashMap<Double, double[]>(); for (int i = 0; i < dataColumn; i++) { map.put(EValueArray[i], storedData.getEigenvector(i).toArray()); } Arrays.sort(EValueArray); xData1 = new double[EValueArray.length]; // for Scree Plot yData1 = new double[EValueArray.length]; for (int i = 0; i < EValueArray.length; i++) { xData1[i] = i + 1; } for (int i = 0; i < EValueArray.length; i++) { yData1[i] = EValueArray[i]; } for (int i = 0; i < yData1.length / 2; i++) { double temp = yData1[i]; yData1[i] = yData1[yData1.length - i - 1]; yData1[yData1.length - i - 1] = temp; } for (int i = 0; i < xData1.length; i++) { System.out.println("xData1 contains: " + xData1[i] + "\n"); } for (int i = 0; i < yData1.length; i++) { System.out.println("yData1 contains: " + yData1[i] + "\n"); } for (int i = 0; i < EValueArray.length / 2; i++) { double temp = EValueArray[i]; EValueArray[i] = EValueArray[EValueArray.length - i - 1]; EValueArray[EValueArray.length - i - 1] = temp; } resultPanelTextArea.append( "Click on \"PCA RESULT\" panel to view the transformed data (Eigenvector Transposed * Adjusted Data Transposed)"); resultPanelTextArea.append("\n\nThe real eigenvalues (in descending order) are: \n\n"); resultPanelTextArea.append("" + round(EValueArray[0], 3)); for (int i = 1; i < EValueArray.length; i++) { resultPanelTextArea.append("\n" + round(EValueArray[i], 3)); } resultPanelTextArea.append("\n\nThe corresponding eigenvectors (in columns) are: \n\n"); double temp[] = new double[100]; for (int j = 0; j < temp.length; j++) for (int i = 0; i < EValueArray.length; i++) { temp = map.get(EValueArray[i]); resultPanelTextArea.append("" + round(temp[j], 3) + "\t"); if (i == EValueArray.length - 1) { resultPanelTextArea.append("\n"); } } doGraph(); }
From source file:gda.device.detector.analyser.EpicsMCASimple.java
private Object getRegionsOfInterest(int noOfRegions) throws DeviceException { Vector<EpicsMCARegionOfInterest> roiVector = new Vector<EpicsMCARegionOfInterest>(); for (int regionIndex = 0; regionIndex < noOfRegions; regionIndex++) { EpicsMCARegionOfInterest rois = getNthRegionOfInterest(regionIndex); roiVector.add(rois);//from w w w.j av a 2 s .co m } if (roiVector.size() != 0) { EpicsMCARegionOfInterest[] selectedrois = new EpicsMCARegionOfInterest[roiVector.size()]; for (int j = 0; j < selectedrois.length; j++) { selectedrois[j] = roiVector.get(j); } return selectedrois; } return null; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.UploadTableTree.java
@Override public Vector<InvalidStructure> verifyUploadability() throws UploaderException, ClassNotFoundException { Vector<InvalidStructure> result = super.verifyUploadability(); if (getTreeDefItem() == null) { String msg = getResourceString("WB_UPLOAD_NO_DEFITEM") + " (" + wbLevelName + ")"; result.add(new InvalidStructure(msg, this)); }//from w w w. jav a 2 s . c om //check for duplicate mappings. This happens if user manages to include both Division and Phylum levels //in the workbench, because they have identical numeric ranks. if (getTreeDefItem() != null) { for (Vector<UploadField> flds : uploadFields) { Vector<Field> fields = new Vector<Field>(); Vector<UploadField> uploadFields = new Vector<UploadField>(); for (UploadField fld : flds) { if (fld.getIndex() != -1) { int idx = fields.indexOf(fld.getField()); if (idx != -1) { String msg = String.format(getResourceString("WB_UPLOAD_EQUIV_RANKS"), fld.getWbFldName(), uploadFields.get(idx).getWbFldName(), getTreeDefItem().getName()); result.add(new InvalidStructure(msg, this)); } else { fields.add(fld.getField()); uploadFields.add(fld); } } } } } if (parent == null) { Vector<TreeDefItemIface<?, ?, ?>> missingDefs = getMissingRequiredDefs(); for (TreeDefItemIface<?, ?, ?> defItem : missingDefs) { String msg = getResourceString("WB_UPLOAD_MISSING_TREE_LEVEL") + " (" + defItem.getName() + ")"; result.add(new InvalidStructure(msg, this)); } } return result; }
From source file:com.globalsight.everest.webapp.pagehandler.tasks.TaskDetailHandler.java
/** * This is copied from CostingEngineLocal The logic is not exactly same but * quite similar./*from w w w . j a v a2s . c o m*/ */ private Rate getActualRateToBeUsed(Task t, String p_acceptor) { Rate useRate = t.getExpenseRate(); int selectionCriteria = t.getRateSelectionCriteria(); User user = null; if (selectionCriteria == WorkflowConstants.USE_SELECTED_RATE_UNTIL_ACCEPTANCE) { // find out who accepted the task try { String acceptor = t.getAcceptor(); if (acceptor != null) { user = ServerProxy.getUserManager().getUser(acceptor); } else { if (p_acceptor != null) { user = ServerProxy.getUserManager().getUser(p_acceptor); } } } catch (Exception e) { CATEGORY.error("TaskDetailHandler::Problem getting user information ", e); } try { // Now find out what is the default rate for this user. if (user != null) { // find out user role Vector uRoles = new Vector(ServerProxy.getUserManager().getUserRoles(user)); String activity = t.getTaskName(); GlobalSightLocale source = t.getSourceLocale(); GlobalSightLocale target = t.getTargetLocale(); for (int i = 0; i < uRoles.size(); i++) { Role curRole = (Role) uRoles.get(i); // Get the source and target locale for each role. String sourceLocale = curRole.getSourceLocale(); String targetLocale = curRole.getTargetLocale(); Activity act = curRole.getActivity(); UserRole cRole = (UserRole) uRoles.get(i); if (act.getActivityName().equals(activity) && sourceLocale.equals(source.toString()) && targetLocale.equals(target.toString())) { // Found the userRole we are talking about if (cRole != null && cRole.getRate() != null) { Long rate = new Long(cRole.getRate()); useRate = getRate(rate.longValue()); } } } } } catch (Exception e) { CATEGORY.error("TaskDetailHandler::Problem getting user information ", e); } } return useRate; }
From source file:gda.scan.ConcurrentScanChild.java
/** * Asynchronously, readout detectors using parallel threads into ScanDataPoint and add to pipeline for possible * completion and publishing. Call {@link ConcurrentScanChild#waitForDetectorReadoutAndPublishCompletion()} to wait * for this task to complete, or {@link #cancelReadoutAndPublishCompletion()} to cancel and interrupt it. * <p>//from www. j a v a 2 s . c om * If the property {@link LocalProperties#GDA_SCAN_CONCURRENTSCAN_READOUT_CONCURRENTLY} is its default false value * then simply block while reading out each detector in series and then adding the ScanDataPoint to the pipeline. * * @param point * @throws Exception */ @Override protected void readoutDetectorsAndPublish(final ScanDataPoint point) throws Exception { final boolean lastPointInLine = (getPointPositionInLine() == PointPositionInLine.LAST); // latch value if (!isReadoutConcurrent()) { super.readoutDetectorsAndPublish(point); return; } // Make sure the previous point has read been published // (If the scan contains a detector this method will already have been called) waitForDetectorReadoutAndPublishCompletion(); final String threadName = "ConcurrentScanChild.readoutDetectorsAndPublish(point '" + point.toString() + "')"; detectorReadoutTask = new FutureTask<Void>(new Callable<Void>() { List<Future<Object>> readoutTasks; /** * Readout each detector in a thread, add the resulting data to the ScanDataPoint and publish. */ @Override public Void call() throws Exception { try { Vector<Detector> detectors = point.getDetectors(); // if there are detectors then readout in parallel threads if (detectors.size() != 0) { readoutTasks = new ArrayList<Future<Object>>(detectors.size()); // Start readout tasks for (Detector detector : point.getDetectors()) { FutureTask<Object> readoutTask = new FutureTask<Object>(new ReadoutDetector(detector)); new Thread(readoutTask, threadName + ": readout '" + detector.getName() + "'").start(); readoutTasks.add(readoutTask); } // Wait for readout results and put into point for (int i = 0; i < detectors.size(); i++) { checkThreadInterrupted(); Object data = readoutTasks.get(i).get(); point.addDetectorData(data, ScannableUtils.getExtraNamesFormats(detectors.get(i))); } } // Put point onto pipeline checkThreadInterrupted(); // probably voodoo and not required here scanDataPointPipeline.put(point); // may block checkThreadInterrupted(); // probably voodoo and not required here // The main scan thread cannot call atPointEnd (and subsequently atPointStart) in the correct order // with respect to readout so call these here instead. for (Detector detector : detectors) { detector.atPointEnd(); } // unless this is the last point in the line, call atPointStart hooks for the next point (the one // that main scan thread is now working on. if (!lastPointInLine) { for (Detector detector : detectors) { detector.atPointStart(); } } } catch (Exception e) { // could be the normal result of cancelling this task // (detector.readout() unfortunately doesn't distinguish InteruptedException from DeviceException logger.info("'" + representThrowable(e) + "' --- while reading out detectors. *Canceling any remaining readout tasks.*"); for (Future<Object> task : readoutTasks) { task.cancel(true); } throw e; } return null; } }); new Thread(detectorReadoutTask, threadName).start(); }
From source file:net.sourceforge.floggy.persistence.Weaver.java
/** * DOCUMENT ME!//w ww. j a v a2 s . c o m * * @param c1 DOCUMENT ME! * @param c2 DOCUMENT ME! * * @throws FloggyException DOCUMENT ME! */ public void mergeConfigurations(Configuration c1, Configuration c2) throws FloggyException { c1.setAddDefaultConstructor(c2.isAddDefaultConstructor()); c1.setGenerateSource(c2.isGenerateSource()); Iterator iterator = c2.getPersistableMetadatas().iterator(); while (iterator.hasNext()) { PersistableMetadata tempMetadata = (PersistableMetadata) iterator.next(); String className = tempMetadata.getClassName(); String suiteName = tempMetadata.getSuiteName(); String vendorName = tempMetadata.getVendorName(); PersistableMetadata currentMetadata = c1.getPersistableMetadata(className); if (((suiteName == null) && (vendorName != null)) || ((suiteName != null) && (vendorName == null))) { throw new FloggyException( "You must provide suite-name and vendor-name for persistable " + className); } if (currentMetadata != null) { String recordStoreName = tempMetadata.getRecordStoreName(); if (!Utils.isEmpty(recordStoreName)) { currentMetadata.setRecordStoreName(recordStoreName.trim()); } int persistableStrategy = tempMetadata.getPersistableStrategy(); if (persistableStrategy > 0) { currentMetadata.setPersistableStrategy(persistableStrategy); } Vector indexMetadatas = tempMetadata.getIndexMetadatas(); if (indexMetadatas != null) { int size = indexMetadatas.size(); for (int i = 0; i < size; i++) { IndexMetadata indexMetadata = (IndexMetadata) indexMetadatas.get(i); int hashCode = Math.abs(className.hashCode()); recordStoreName = "Index" + hashCode + indexMetadata.getName(); indexMetadata.setRecordStoreName(recordStoreName); Vector fields = indexMetadata.getFields(); for (int j = 0; j < fields.size(); j++) { String fieldName = (String) fields.get(j); if (!containsField(className, fieldName)) { throw new FloggyException("The field " + fieldName + " that compounds the index " + indexMetadata.getName() + " does not exist on persistable " + className); } else if (!isIndexableField(className, fieldName)) { throw new FloggyException("The field " + fieldName + " that compounds the index " + indexMetadata.getName() + " on persistable " + className + " it is not from a valid type"); } } } currentMetadata.setIndexMetadatas(indexMetadatas); } } } }
From source file:com.hihframework.core.utils.DateUtils.java
/** * ?/*w w w . jav a 2 s. c o m*/ * start * end? * * 2002-05-232002-07-152002-05-23?2002-06-01?2002-07-15 * ??? */ public static Date[][] getMonthDividedDateList(java.sql.Date startDate, java.sql.Date endDate) { Date[][] result = new Date[0][2]; if ((startDate != null) && (endDate != null)) { Date start = (startDate.getTime() > endDate.getTime()) ? endDate : startDate; Date end = (startDate.getTime() < endDate.getTime()) ? endDate : startDate; java.util.Vector<Object> v = new java.util.Vector<Object>(); // cal.setTime(new java.util.Date(start.getTime())); int month = cal.get(Calendar.MONTH); // ? cal.setTime(new java.util.Date(end.getTime())); long endtime = end.getTime(); long tmptime = 0; v.add(start); do { // ?? cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); tmptime = cal.getTime().getTime(); if (tmptime <= endtime) { v.add(new Date(tmptime)); // ? cal.set(Calendar.MONTH, month + 1); cal.set(Calendar.DAY_OF_MONTH, 1); tmptime = cal.getTime().getTime(); if (tmptime <= endtime) { v.add(new Date(tmptime)); } } month++; } while (tmptime < endtime); v.add(end); result = new Date[v.size() / 2][2]; for (int i = 0; i < result.length; i++) { result[i][0] = (Date) v.get((i * 2) + 0); result[i][1] = (Date) v.get((i * 2) + 1); } v.removeAllElements(); } return result; }
From source file:com.evolveum.openicf.lotus.DominoConnector.java
private Registration createAndSetupRegistration(Map<String, Attribute> attrs, OperationOptions options, String firstName, String lastName, String orgUnit, String mailTemplate, Integer mailQuotaSize, Integer mailQuotaWThreshold, String certPw) throws NotesException { Vector<String> shortNameVector = getAttributeValue(attrs, SHORT_NAME, Vector.class, null, false); String shortName = null;/*from w ww .jav a 2 s .c o m*/ if (shortNameVector != null && !shortNameVector.isEmpty()) { shortName = shortNameVector.get(0); } String policy = getAttributeValue(attrs, POLICY, String.class, config.getPolicy()); Integer defaultPasswordExp = getAttributeValue(attrs, DEFAULT_PASSWORD_EXP, Integer.class); Integer days = getDays(getAttributeValue(attrs, END_DATE, Long.class)); if (defaultPasswordExp == null) { if (days != null && days > 0L) { defaultPasswordExp = days; } else { defaultPasswordExp = config.getDefaultPasswordExp(); } } Vector altOrgUnit = getAttributeValue(attrs, ALT_ORG_UNIT, Vector.class); Vector mailReplicaServers = getAttributeValue(attrs, ROAM_RPL_SRVRS, Vector.class); Boolean northAmerican = getAttributeValue(attrs, NORTH_AMERICAN, Boolean.class, config.getNorthAmerican()); String certifierIdFile = getAttributeValue(attrs, CERTIFIER_ID_FILE, String.class, config.getCertifierIdFile()); String caCertifier = getAttributeValue(attrs, CA_CERTIFIER, String.class, config.getCaCertifierName()); if (config.getUseCAProcess() != null && config.getUseCAProcess()) { if (StringUtils.isEmpty(caCertifier)) { throw new ConnectorException( "Using CA process, but CA certifier name not defined (caCertifier attribute)."); } } else { if (StringUtils.isEmpty(certifierIdFile)) { throw new ConnectorException("Certifier ID file not defined."); } if (StringUtils.isEmpty(certPw)) { throw new ConnectorException("Cert. password (credentials) attribute not defined."); } } //roaming String roamSrvr = getAttributeValue(attrs, ROAM_SRVR, String.class, config.getRoamSrvr()); Integer roamCleanSetting = getAttributeValue(attrs, ROAM_CLEAN_SETTING, Integer.class, config.getRoamCleanSetting()); Integer roamCleanPer = getAttributeValue(attrs, ROAM_CLEAN_PER, Integer.class, config.getRoamCleanPer()); String roamSubDir = getAttributeValue(attrs, ROAM_SUBDIR, String.class, PREFIX_ROAMING + firstName + lastName); //groups validation Vector groups = getAttributeValue(attrs, GROUP_LIST, Vector.class); checkIfGroupsExist(groups); String internetAddress = getAttributeValue(attrs, INTERNET_ADDRESS); Boolean synchInternetPassword = getOperationOptionValue(options, SYNCH_INTERNET_PASSWORD, null); Integer mailOwnerAccess = getOperationOptionValue(options, MAIL_OWNER_ACCESS, config.getMailOwnerAccess()); LOG.ok("Creating registration."); Registration registration = connection.getSession().createRegistration(); RegistrationBuilder builder = new RegistrationBuilder(registration); builder.setCertifierName(caCertifier); builder.setPolicyName(policy); builder.setShortName(shortName); builder.setOrgUnit(orgUnit); builder.setAltOrgUnit(altOrgUnit); builder.setCertifierIDFile(certifierIdFile); builder.setMailTemplateName(mailTemplate); builder.setMailQuotaSizeLimit(mailQuotaSize); builder.setMailQuotaWarningThreshold(mailQuotaWThreshold); builder.setGroupList(groups); builder.setRoamingServer(roamSrvr); builder.setRoamingCleanupSetting(roamCleanSetting); builder.setRoamingCleanupPeriod(roamCleanPer); builder.setRoamingSubdir(roamSubDir); builder.setMailInternetAddress(internetAddress); builder.setSynchInternetPassword(synchInternetPassword); builder.setMailOwnerAccess(mailOwnerAccess); builder.setMailReplicaServers(mailReplicaServers); builder.setNorthAmerican(northAmerican); builder.setRegistrationLog(config.getRegistrationLog()); builder.setStoreIDInAddressBook(config.getStoreIDInAddressBook()); builder.setStoreIDInMailfile(config.getStoreIDInMailfile()); builder.setIDType(config.getRealIdType()); builder.setMailSystem(config.getMailSystem()); builder.setCreateMailDb(config.getCreateMailDb()); builder.setMinPasswordLength(config.getMinPasswordLength()); builder.setUpdateAddressBook(true); if (StringUtils.isNotEmpty(config.getMailACLManager())) { builder.setMailACLManager(config.getMailACLManager()); } builder.setMailACLManager("LocalDomainAdmins"); if (config.getCreateIdFile() != null && !config.getCreateIdFile()) { builder.setNoIDFile(true); builder.setCertifierName(config.getAdminName()); } DateTime expiration = connection.getSession().createDateTime("Today"); expiration.setNow(); expiration.adjustDay(defaultPasswordExp); builder.setExpiration(expiration); return registration; }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoCategorizedDocuments.java
private void setup(Document curDoc) { try {/*from ww w . ja v a 2 s . c om*/ DAVRepositoryDominoCategorizedDocuments rep = (DAVRepositoryDominoCategorizedDocuments) this .getRepository(); LOGGER.info("Start setup with doc ..." + curDoc.getItemValueString(rep.getPubHrefField())); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); // LOGGER.info(getCallingMethod()+":"+"All Embedded computed"); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).equals("") ? 0 : allEmbedded.size()); String docID = curDoc.getUniversalID(); this.setDocumentUniqueID(docID); LOGGER.info("Num of attachments=" + new Integer(numOfAttachments).toString()); boolean readOnly = this.checkReadOnlyAccess(curDoc); this.setReadOnly(readOnly); // LOGGER.info("Creation date for "+curDoc.getUniversalID()+" ="+curDoc.getCreated().toString()+"; Time zone="+curDoc.getCreated().getZoneTime()+"; Local time="+curDoc.getCreated().getLocalTime()); Date curCreationDate = curDoc.getCreated().toJavaDate(); // LOGGER.info("Current date in Java is "+curCreationDate.toString()+"Time zone="+new // Integer(curCreationDate.getTimezoneOffset()).toString()+"; Locale time is:"+curCreationDate.toLocaleString()); if (curDoc.hasItem("DAVCreated")) { // Item davCreated=curDoc.getFirstItem("DAVCreated"); @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); if (curCreationDate == null) { curCreationDate = curDoc.getCreated().toJavaDate(); } } } } } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); if (curChangeDate == null) { curChangeDate = curDoc.getLastModified().toJavaDate(); } } } } } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); // LOGGER.info("Creation date is set to "+this.getCreationDate().toString()); // LOGGER.info("Last modified date is set to "+this.getLastModified().toString()); String pubHRef = ((IDAVAddressInformation) this.getRepository()).getPublicHref(); // LOGGER.info("THIS getpublichref="+this.getPublicHref()); String curAttName = null; if (numOfAttachments == 0) { // LOGGER.info(getCallingMethod()+":"+"Start setting resource"); String name = curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getDirectoryField()); this.setName(name); if (this.getPublicHref().equals("")) { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getPubHrefField())); } this.setCollection(true); this.setInternalAddress( ((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID); this.setResourceType("NotesDocument"); this.setMember(false); this.setContentLength(0L); // this.fetchChildren(); } else { curAttName = allEmbedded.get(0).toString(); // LOGGER.info("Attachment name is "+curAttName); this.setMember(true); this.setResourceType("NotesAttachment"); if (this.getPublicHref().equals("")) { try { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())) .getPubHrefField())); } catch (Exception e) { LOGGER.error(e); } // this.setPublicHref( pubHRef+"/"+curAttName); } this.setInternalAddress(((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID + "/$File/" + curAttName); this.setCollection(false); this.setName(curAttName); EmbeddedObject curAtt = curDoc.getAttachment(curAttName); if (curAtt == null) { return; } Long curSize = new Long(curAtt.getFileSize()); this.setContentLength(curSize); } // LOGGER.info("Current res realized! pubHREF="+this.getPublicHref()+"; Internal Address="+this.getInternalAddress()+"; "); } catch (NotesException ne) { LOGGER.error("ERROR! Can not set; " + ne.getMessage()); } }
From source file:eionet.gdem.dcm.business.SchemaManager.java
/** * Get XML schema information from database. The info can be queried by XML Schema URL or by schema database ID. * The return object holds also information about the user permissions and Schema root elements. * @param userName User login name who is asking the schema information * @param schemaId Accepts both type of IDs: XML schema numeric database ID or XML Schema URL * @return SchemaElemHolder object holding XML Schema and user rights information * @throws DCMException in case of database error occurred. *//*from www. j a v a 2 s . c om*/ public SchemaElemHolder getSchemaElems(String userName, String schemaId) throws DCMException { SchemaElemHolder se = new SchemaElemHolder(); boolean xsduPrm = false; boolean xsddPrm = false; String schemaDbId = "0"; Schema schema; List<RootElem> elems; try { elems = new ArrayList<RootElem>(); xsduPrm = SecurityUtil.hasPerm(userName, "/" + Names.ACL_SCHEMA_PATH, "u"); xsddPrm = SecurityUtil.hasPerm(userName, "/" + Names.ACL_SCHEMA_PATH, "d"); se.setXsduPrm(xsduPrm); se.setXsddPrm(xsddPrm); Vector list = schemaDao.getSchemas(schemaId, false); if (list == null) { list = new Vector(); } if (list.size() > 0) { schema = new Schema(); HashMap schemaHash = (HashMap) list.get(0); schemaDbId = (String) schemaHash.get("schema_id"); schema.setId(schemaDbId); schema.setSchema((String) schemaHash.get("xml_schema")); schema.setDescription((String) schemaHash.get("description")); schema.setSchemaLang((String) schemaHash.get("schema_lang")); boolean validate = (!Utils.isNullStr((String) schemaHash.get("validate")) && ((String) schemaHash.get("validate")).equals("1")); schema.setDoValidation(validate); schema.setDtdPublicId((String) schemaHash.get("dtd_public_id")); schema.setExpireDate( Utils.parseDate((String) schemaHash.get("expire_date"), "yyyy-MM-dd HH:mm:ss")); boolean blocker = (!Utils.isNullStr((String) schemaHash.get("blocker")) && ((String) schemaHash.get("blocker")).equals("1")); schema.setBlocker(blocker); // get uploaded schema information HashMap uplSchemaMap = uplSchemaDao.getUplSchemaByFkSchemaId(schemaDbId); if (uplSchemaMap != null && uplSchemaMap.get("upl_schema_file") != null) { UplSchema uplSchema = new UplSchema(); String uplSchemaFile = (String) uplSchemaMap.get("upl_schema_file"); String uplSchemaId = (String) uplSchemaMap.get("upl_schema_id"); String uplSchemaFileUrl = Properties.gdemURL + "/schema/" + uplSchemaFile; if (!Utils.isNullStr(uplSchemaFile)) { try { File f = new File(Properties.schemaFolder, uplSchemaFile); if (f != null) { uplSchema.setLastModified(Utils.getDateTime(new Date(f.lastModified()))); } } catch (Exception e) { LOGGER.error("unable to read schema file last modified time.", e); } } uplSchema.setUplSchemaId(uplSchemaId); uplSchema.setUplSchemaFile(uplSchemaFile); uplSchema.setUplSchemaFileUrl(uplSchemaFileUrl); schema.setUplSchema(uplSchema); schema.setUplSchemaFileName(uplSchemaFile); } se.setSchema(schema); } Vector rootElems = rootElemDao.getSchemaRootElems(schemaDbId); if (rootElems == null) { rootElems = new Vector(); } for (int i = 0; i < rootElems.size(); i++) { HashMap hash = (HashMap) rootElems.get(i); RootElem rElem = new RootElem(); rElem.setElemId((String) hash.get("rootelem_id")); rElem.setName((String) hash.get("elem_name")); rElem.setNamespace((String) hash.get("namespace")); elems.add(rElem); } if (elems.size() > 0) { se.setRootElem(elems); } } catch (Exception e) { e.printStackTrace(); LOGGER.error("Error getting root elements", e); throw new DCMException(BusinessConstants.EXCEPTION_GENERAL); } return se; }