List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:org.apache.axis.wsdl.toJava.Utils.java
/** * If the specified node represents a supported JAX-RPC enumeration, * a Vector is returned which contains the base type and the enumeration values. * The first element in the vector is the base type (an TypeEntry). * Subsequent elements are values (Strings). * If this is not an enumeration, null is returned. * * @param node/*from ww w .j a v a2 s . c om*/ * @param symbolTable * @return */ public static Vector getEnumerationBaseAndValues(Node node, SymbolTable symbolTable) { if (node == null) { return null; } // If the node kind is an element, dive into it. QName nodeKind = Utils.getNodeQName(node); if ((nodeKind != null) && nodeKind.getLocalPart().equals("element") && Constants.isSchemaXSD(nodeKind.getNamespaceURI())) { NodeList children = node.getChildNodes(); Node simpleNode = null; for (int j = 0; (j < children.getLength()) && (simpleNode == null); j++) { QName simpleKind = Utils.getNodeQName(children.item(j)); if ((simpleKind != null) && simpleKind.getLocalPart().equals("simpleType") && Constants.isSchemaXSD(simpleKind.getNamespaceURI())) { simpleNode = children.item(j); node = simpleNode; } } } // Get the node kind, expecting a schema simpleType nodeKind = Utils.getNodeQName(node); if ((nodeKind != null) && nodeKind.getLocalPart().equals("simpleType") && Constants.isSchemaXSD(nodeKind.getNamespaceURI())) { // Under the simpleType there should be a restriction. // (There may be other #text nodes, which we will ignore). NodeList children = node.getChildNodes(); Node restrictionNode = null; for (int j = 0; (j < children.getLength()) && (restrictionNode == null); j++) { QName restrictionKind = Utils.getNodeQName(children.item(j)); if ((restrictionKind != null) && restrictionKind.getLocalPart().equals("restriction") && Constants.isSchemaXSD(restrictionKind.getNamespaceURI())) { restrictionNode = children.item(j); } } // The restriction node indicates the type being restricted // (the base attribute contains this type). // The base type must be a simple type, and not boolean TypeEntry baseEType = null; if (restrictionNode != null) { QName baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false); baseEType = symbolTable.getType(baseType); if (baseEType != null) { String javaName = baseEType.getName(); if (javaName.equals("boolean") || !SchemaUtils.isSimpleSchemaType(baseEType.getQName())) { baseEType = null; } } } // Process the enumeration elements underneath the restriction node if ((baseEType != null) && (restrictionNode != null)) { Vector v = new Vector(); NodeList enums = restrictionNode.getChildNodes(); for (int i = 0; i < enums.getLength(); i++) { QName enumKind = Utils.getNodeQName(enums.item(i)); if ((enumKind != null) && enumKind.getLocalPart().equals("enumeration") && Constants.isSchemaXSD(enumKind.getNamespaceURI())) { // Put the enum value in the vector. Node enumNode = enums.item(i); String value = Utils.getAttribute(enumNode, "value"); if (value != null) { v.add(value); } } } // is this really an enumeration? if (v.isEmpty()) { return null; } // The first element in the vector is the base type (an TypeEntry). v.add(0, baseEType); return v; } } return null; }
From source file:org.wise.portal.presentation.web.controllers.ContactWiseController.java
@RequestMapping(method = RequestMethod.POST) public String onSubmit(@ModelAttribute("contactWISEForm") ContactWISEForm contactWISEForm, BindingResult result, HttpServletRequest request) throws Exception { contactWISEValidator.validate(contactWISEForm, result); checkRecaptcha(request, result);/*from w w w. ja v a 2 s . co m*/ getTeacherNameAndSetInForm(contactWISEForm); if (result.hasErrors()) { return "contact/contactwise"; } // get our user key for the user agent parse site String userKey = wiseProperties.getProperty("userAgentParseKey"); if (userKey != null && !userKey.equals("")) { // get the user agent from the request String userAgent = request.getParameter("usersystem"); HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(userAgentParseURL); // add the user_key and user_agent parameters to the POST request List<NameValuePair> urlParameters = new ArrayList<NameValuePair>(); urlParameters.add(new BasicNameValuePair("user_key", userKey)); urlParameters.add(new BasicNameValuePair("user_agent", userAgent)); post.setEntity(new UrlEncodedFormEntity(urlParameters)); try { // execute the POST HttpResponse response = client.execute(post); // read the response BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer userAgentParseResult = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { userAgentParseResult.append(line); } String parseResultString = userAgentParseResult.toString(); try { // get the response as a JSON object JSONObject parseResultJSONObject = new JSONObject(parseResultString); // get whether the request succeeded String parseResult = parseResultJSONObject.getString("result"); if (parseResult != null && parseResult.equals("success")) { // the request succeeded so we will get the data JSONObject parse = parseResultJSONObject.getJSONObject("parse"); // get the operating system and browser values String operatingSystemName = parse.getString("operating_system_name"); String operatingSystemVersion = parse.getString("operating_system_version_full"); String browserName = parse.getString("browser_name"); String browserVersion = parse.getString("browser_version_full"); // set the values into the form so that we can use them later when creating the email message contactWISEForm.setOperatingSystemName(operatingSystemName); contactWISEForm.setOperatingSystemVersion(operatingSystemVersion); contactWISEForm.setBrowserName(browserName); contactWISEForm.setBrowserVersion(browserVersion); } } catch (JSONException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } //retrieves the contents of the email to be sent String[] recipients = getMailRecipients(); String[] cc = getMailCcs(contactWISEForm); String subject = contactWISEForm.getMailSubject(); String fromEmail = contactWISEForm.getEmail(); String message = contactWISEForm.getMailMessage(); //fromEmail will be null if the signed in user is a student if (fromEmail == null) { /* * set the fromEmail to a non null and non empty string otherwise * an exception will be thrown */ fromEmail = "null"; } //get the run id Long runId = contactWISEForm.getRunId(); /* * if a student is submitting the contactwiseproject form, the runId will * be set. if a teacher is submitting the contactwiseproject form, the * runId will not be set. this is ok because the teacher is the run * owner and their email is already in the cc array */ if (runId != null) { Run run = runService.retrieveById(runId); Vector<String> runOwnerEmailAddresses = new Vector<String>(); User runOwner = run.getOwner(); MutableUserDetails userDetails = runOwner.getUserDetails(); //get the run owner email address String emailAddress = userDetails.getEmailAddress(); if (emailAddress != null) { runOwnerEmailAddresses.add(emailAddress); } if (!runOwnerEmailAddresses.isEmpty()) { //we have run owner email addresses for (int x = 0; x < cc.length; x++) { if (!runOwnerEmailAddresses.contains(cc[x])) { //add the cc emails to the run owner emails to merge them runOwnerEmailAddresses.add(cc[x]); } } //create a new String array the same size as the runOwnerEmailAddresses cc = new String[runOwnerEmailAddresses.size()]; //put all the email addresses back into the cc array for (int x = 0; x < runOwnerEmailAddresses.size(); x++) { cc[x] = runOwnerEmailAddresses.get(x); } } } //for testing out the email functionality without spamming the groups if (DEBUG) { cc = new String[1]; cc[0] = fromEmail; recipients[0] = DEBUG_EMAIL; } //sends the email to the recipients mailService.postMail(recipients, subject, message, fromEmail, cc); return "contact/contactwiseconfirm"; }
From source file:org.ecoinformatics.seek.datasource.eml.eml2.Eml200DataSource.java
/** * Method to transform a string to token based on given type and * missingValue.//from w w w .j ava 2s .c o m */ static Token transformStringToToken(String eleStr, Type type, Vector missingValue, String columnName) throws IllegalActionException { Token val = null; if (missingValue != null && !missingValue.isEmpty()) { if (missingValue.contains(eleStr)) { eleStr = null; } } String elementError = "Element \""; String errorMessage1 = "\" couldn't be in the "; String errorMessage2 = " column " + columnName + ". It probably is a missing value code, however metadata " + "doesn't describe it. Please make a double check."; // find the data type for each att if (type == BaseType.INT) { if (eleStr != null && !eleStr.equals("")) { try { val = new IntToken(new Integer(eleStr).intValue()); } catch (NumberFormatException e) { throw (new IllegalActionException( elementError + eleStr + errorMessage1 + "integer" + errorMessage2)); } } else { // eleStr = null; val = IntToken.NIL; // val.nil(); } } else if (type == BaseType.DOUBLE) { if (eleStr != null && !eleStr.equals("")) { try { val = new DoubleToken(new Double(eleStr).doubleValue()); } catch (NumberFormatException e) { throw (new IllegalActionException( elementError + eleStr + errorMessage1 + "numerical" + errorMessage2)); } } else { // eleStr = null; val = DoubleToken.NIL; } } else if (type == BaseType.LONG) { if (eleStr != null && !eleStr.equals("")) { try { val = new LongToken(new Long(eleStr).longValue()); } catch (NumberFormatException e) { throw (new IllegalActionException( elementError + eleStr + errorMessage1 + "numerical" + errorMessage2)); } } else { // eleStr = null; val = LongToken.NIL; // val.nil(); } } else if (type == BaseType.STRING) { if (eleStr != null) { val = new StringToken(eleStr); } else { // eleStr = "nil"; val = StringToken.NIL; // val.nil(); } } else { val = new IntToken(0); } return val; }
From source file:org.ecoinformatics.datamanager.database.DatabaseAdapter.java
/** * Creates a SQL command to insert data. If some error happens, null will be * returned.// w w w . jav a2s.c o m * * @param attributeList AttributeList which will be inserted * @param tableName The name of the table which the data will be inserted into * @param oneRowData The data vector which contains data to be inserted * @return A SQL String that can be run to insert one row of data into table */ public String generateInsertSQL(AttributeList attributeList, String tableName, Vector oneRowData) throws DataNotMatchingMetadataException, SQLException { String sqlString = null; int NULLValueCounter = 0; int hasValueCounter = 0; if (attributeList == null) { //log.debug("There is no attribute definition in entity"); throw new SQLException("The attribute list is null and couldn't generate insert sql statement"); } if (oneRowData == null || oneRowData.isEmpty()) { //return sqlString; throw new SQLException("The the data is null and couldn't generte insert sql statement"); } StringBuffer sqlAttributePart = new StringBuffer(); StringBuffer sqlDataPart = new StringBuffer(); sqlAttributePart.append(INSERT); sqlAttributePart.append(SPACE); sqlAttributePart.append(tableName); sqlAttributePart.append(LEFTPARENTH); sqlDataPart.append(SPACE); sqlDataPart.append(VALUES); sqlDataPart.append(SPACE); sqlDataPart.append(LEFTPARENTH); Attribute[] list = attributeList.getAttributes(); if (list == null || list.length == 0) { //log.debug("There is no attribute definition in entity"); //return sqlString; throw new SQLException("The attributes is null and couldn't generate insert sql statement"); } int size = list.length; // column name part boolean firstAttribute = true; for (int i = 0; i < size; i++) { // if data vector Object obj = oneRowData.elementAt(i); String value = null; if (obj == null) { NULLValueCounter++; continue; } else { value = (String) obj; if (value.trim().equals("")) { continue; } } Attribute attribute = list[i]; if (attribute == null) { //log.debug("One attribute definition is null attribute list"); //return null; throw new SQLException("Attribute list contains a null attribute"); } String[] missingValues = attribute.getMissingValueCode(); boolean isMissingValue = isMissingValue(value, missingValues); if (isMissingValue) { continue; } String name = attribute.getDBFieldName(); String attributeType = getAttributeType(attribute); if (!firstAttribute) { sqlAttributePart.append(COMMA); sqlDataPart.append(COMMA); } sqlAttributePart.append(name); Domain domain = attribute.getDomain(); //System.out.println("the value in element is "+value); /* If attributeType is "datetime", convert to a timestamp * and wrap single quotes around the value. But only if we * have a format string! */ if (attributeType.equalsIgnoreCase("datetime")) { String formatString = ((DateTimeDomain) domain).getFormatString(); //System.out.println("in DateTimeDomain " + value); value = escapeSpecialCharacterInData(value); sqlDataPart.append(TO_DATE_FUNCTION); sqlDataPart.append(LEFTPARENTH); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(value); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(COMMA); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(formatString); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(RIGHTPARENTH); hasValueCounter++; log.debug("datetime value expression= " + sqlDataPart.toString()); } /* If domain is null or it is not NumericDomain we assign it text type * and wrap single quotes around the value. */ else if (attributeType.equals("string")) { //System.out.println("in non NumericDomain " + value); value = escapeSpecialCharacterInData(value); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(value); sqlDataPart.append(SINGLEQUOTE); hasValueCounter++; } /* Else we have a NumericDomain. Determine whether it is a float or * integer. */ else { String dataType = mapDataType(attributeType); try { if (dataType.equals("FLOAT")) { //System.out.println("in float NumericDomain " + value); Float floatObj = new Float(value); /* System.out.println("after generating floatObj numericDomain " + value); */ float floatNum = floatObj.floatValue(); //System.out.println("float number " + floatNum); sqlDataPart.append(floatNum); //System.out.println("end of float"); } else { //System.out.println("in integer NumericDomain " + value); Integer integerObj = new Integer(value); //System.out.println("after generate Integer Obj NumericDomain " // + value); int integerNum = integerObj.intValue(); //System.out.println("the int value is " + integerNum); sqlDataPart.append(integerNum); //System.out.println("end of integer"); } } catch (Exception e) { System.out.println("Error determining numeric value: " + e.getMessage()); //return sqlString; throw new DataNotMatchingMetadataException( "Data " + value + " is NOT a " + dataType + " : " + e.getMessage()); } hasValueCounter++; } firstAttribute = false; // insert } // If all data is null, return null value for sql string. if (NULLValueCounter == list.length || hasValueCounter == 0) { return sqlString; //throw new SQLException("All data is null and couldn't generate insert data statement"); } sqlAttributePart.append(RIGHTPARENTH); sqlDataPart.append(RIGHTPARENTH); sqlDataPart.append(SEMICOLON); // Combine the two parts sqlAttributePart.append(sqlDataPart.toString()); sqlString = sqlAttributePart.toString(); //System.out.println("the sql command is " + sqlString); return sqlString; }
From source file:edu.harvard.i2b2.eclipse.plugins.metadataLoader.views.loader.TableComposite.java
public void processSchemes() throws Exception { OntologyResponseMessage msg = new OntologyResponseMessage(); StatusType procStatus = null;/*from ww w . j av a2 s.c o m*/ CSVFileReader reader = null; try { String file = RunData.getInstance().getSchemesFile(); reader = new CSVFileReader(RunData.getInstance().getSchemesFile(), '|', '"'); // Read in header.. reader.readFields(); int count = 0; int start = 1; int end = 10; MetadataLoadType schemes = new MetadataLoadType(); schemes.setTableName("SCHEMES"); Vector<String> fields = null; while (count < end) { try { fields = reader.readFields(); if ((fields == null) || (fields.isEmpty())) { if (schemes.getMetadata().isEmpty()) break; System.out.println("Loading scheme records " + start + " to " + count); String response = OntServiceDriver.loadMetadata(schemes, "ONT"); procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading schemes records: exiting"); break; } break; } } catch (Exception e) { // TODO Auto-generated catch block reader.close(); System.out.println("Error loading scheme records: exiting"); System.exit(1); } if (fields.size() < 3) { System.out.println("problem; too few fields."); I2B2Exception e2 = new I2B2Exception( "Error processinging schemes records: too few fields in file; exiting "); throw e2; } MetadataLoaderType scheme = new MetadataLoaderType(); schemes.getMetadata().add(scheme.fromSchemes(fields)); count++; if (end == count) { System.out.println("Loading scheme records " + start + " to " + count); try { String response = OntServiceDriver.loadMetadata(schemes, "ONT"); procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading schemes records: exiting"); break; } } catch (Exception e) { // TODO Auto-generated catch block reader.close(); System.out.println("Error loading scheme records: exiting"); System.exit(1); } // list.clear(); end += 10; start += 10; } } reader.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("Schemes loader complete"); }
From source file:edu.harvard.i2b2.eclipse.plugins.metadataLoader.views.loader.TableComposite.java
public void processTableAccess() throws Exception { OntologyResponseMessage msg = new OntologyResponseMessage(); StatusType procStatus = null;/* w w w . ja v a 2 s . c o m*/ CSVFileReader reader = null; try { String file = RunData.getInstance().getTableAccessFile(); reader = new CSVFileReader(RunData.getInstance().getTableAccessFile(), '|', '"'); // Read in header.. reader.readFields(); int count = 0; int start = 1; int end = 10; MetadataLoadType categories = new MetadataLoadType(); categories.setTableName("TABLE_ACCESS"); Vector<String> fields = null; while (count < end) { try { fields = reader.readFields(); if ((fields == null) || (fields.isEmpty())) { if (categories.getMetadata().isEmpty()) break; System.out.println("Loading table_access records " + start + " to " + count); String response = OntServiceDriver.loadMetadata(categories, "ONT"); // look at response for error // This one loads data reached when end of file found. // This is call to ONT to load the table access data. procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading table_access records: exiting"); I2B2Exception e = new I2B2Exception(procStatus.getValue()); throw e; } break; } } catch (Exception e) { reader.close(); System.out.println("Error loading table_access records: exiting"); I2B2Exception e2 = new I2B2Exception( "Error loading table_access records; exiting: " + e.getMessage()); throw e2; } if (fields.size() < 23) { System.out.println("problem; too few fields."); I2B2Exception e2 = new I2B2Exception( "Error processing table_access records: too few fields in file; exiting "); throw e2; } // This design assumes that the table_access file only lists one metadata table. /// It can have multiple rows, but can only refer to one table to create/load. String metadataTable = fields.get(1); if (metadataTable == null) { reader.close(); System.out.println("No metadata table specified in table access record; quitting."); break; } RunData.getInstance().setMetadataTable(fields.get(1)); MetadataLoaderType category = new MetadataLoaderType(); OntologyDataType data = category.fromTableAccess(fields); categories.getMetadata().add(data); count++; // This one loads data reached after we read in a "chunk" of data.. if (end == count) { System.out.println("Loading table_access records " + start + " to " + end); try { String response = OntServiceDriver.loadMetadata(categories, "ONT"); procStatus = msg.processResult(response); if (procStatus.getType().equals("ERROR")) { System.setProperty("errorMessage", procStatus.getValue()); reader.close(); System.out.println("Error loading table_access records: exiting"); I2B2Exception e = new I2B2Exception(procStatus.getValue()); throw e; } } catch (Exception e) { // TODO Auto-generated catch block reader.close(); System.out.println("Error loading table_access records: exiting"); I2B2Exception e2 = new I2B2Exception( "Error loading table_access records; exiting: " + e.getMessage()); throw e2; } categories.getMetadata().clear(); // list.clear(); end += 10; start += 10; } } reader.close(); } catch (FileNotFoundException e1) { I2B2Exception e2 = new I2B2Exception("Error loading table_access records; exiting: " + e1.getMessage()); throw e2; } catch (IOException e1) { I2B2Exception e2 = new I2B2Exception("Error loading table_access records; exiting: " + e1.getMessage()); throw e2; } System.out.println("Table access loader complete"); }
From source file:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java
private void updateEML(boolean originalDataFileIncorrect) { // Get eml document first Vector list = getDocumentList(); //If list is not empty, goes through every document by handleSingleEML method - //1. It will read the eml from Metacat. // 2. Get online URL information from eml document by DOM parser. // 3. Base on the URL information, this program will find the data file in // the direcotry which contains the srb data file. // 4. It will generate docid for the data file // 5. At last upload the download srb data file to Metacat with assigned docid. // 6. Modify the eml document with the new URL information (pointing to // knb) and new version number in eml. // 7.Update it to a new version in Metacat. if (list != null && !list.isEmpty()) { int size = list.size(); for (int i = 0; i < size; i++) { String docid = null;//from w w w . j av a2 s. c o m try { docid = (String) list.elementAt(i); String dataId = handleSingleEML(docid, originalDataFileIncorrect); String message = "Successfully update eml " + docid + " with data id " + dataId; writeLog(log, message); } catch (Exception e) { System.err.println("Failed to handle eml document " + docid + " since " + e.getMessage()); String message = "failed to update eml " + docid + "\n " + e.getMessage(); writeLog(error, message); } } } else { System.err.println("There is no EML document to handle"); } }
From source file:org.apache.activemq.JmsConnectionStartStopTest.java
public void testConcurrentSessionCreateWithStart() throws Exception { ThreadPoolExecutor executor = new ThreadPoolExecutor(50, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); final Vector<Throwable> exceptions = new Vector<Throwable>(); final Random rand = new Random(); Runnable createSessionTask = new Runnable() { @Override/*from www . jav a2 s . c om*/ public void run() { try { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (Exception e) { exceptions.add(e); } } }; Runnable startStopTask = new Runnable() { @Override public void run() { try { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.start(); stoppedConnection.stop(); } catch (Exception e) { exceptions.add(e); } } }; for (int i = 0; i < 1000; i++) { executor.execute(createSessionTask); executor.execute(startStopTask); } executor.shutdown(); assertTrue("executor terminated", executor.awaitTermination(30, TimeUnit.SECONDS)); assertTrue("no exceptions: " + exceptions, exceptions.isEmpty()); }
From source file:programs.bwa_mem.java
@Override public boolean init_checkRequirements() { // In case program is started without edition pgrmStartWithoutEdition(properties); // TEST OUTPUT PATH String specificId = Util.returnRandomAndDate(); if (properties.isSet("ObjectID")) { String oId = properties.get("ObjectID"); oId = Util.replaceSpaceByUnderscore(oId); specificId = specificId + "_" + oId; }/* w ww.j a va 2s . c o m*/ String specificPath = outputsPath + specificId; if (!Util.CreateDir(specificPath) && !Util.DirExists(specificPath)) { setStatus(status_BadRequirements, Util.BROutputsDir()); return false; } // TEST INPUT VARIABLES HERE // ports are 3-PortInputUp, 2-PortInputDOWN, 4-PortInputDOWN2 Vector<Integer> GenomeFile1 = properties.getInputID("GenomeFile", PortInputDOWN2); inputPath1 = GenomeFile.getVectorFilePath(GenomeFile1); inputId1 = GenomeFile.getVectorFileId(GenomeFile1); input1 = Util.getFileNameAndExt(inputPath1); Vector<Integer> FastaFile2 = properties.getInputID("FastaFile", PortInputDOWN2); inputPath2 = FastaFile.getVectorFilePath(FastaFile2); inputId2 = FastaFile.getVectorFileId(FastaFile2); input2 = Util.getFileNameAndExt(inputPath2); Vector<Integer> FastqFile3 = properties.getInputID("FastqFile", PortInputDOWN); inputPath3 = FastqFile.getVectorFilePath(FastqFile3); inputId3 = FastqFile.getVectorFileId(FastqFile3); input3 = Util.getFileNameAndExt(inputPath3); Vector<Integer> FastqFile4 = properties.getInputID("FastqFile", PortInputUP); inputPath4 = FastqFile.getVectorFilePath(FastqFile4); inputId4 = FastqFile.getVectorFileId(FastqFile4); input4 = Util.getFileNameAndExt(inputPath4); //INSERT YOUR INPUT TEST HERE if ((GenomeFile1.isEmpty() || input1.equals("Unknown") || input1.equals("")) && (FastaFile2.isEmpty() || input2.equals("Unknown") || input2.equals(""))) { setStatus(status_BadRequirements, Util.BRTypeFile("FastaFile")); return false; } /* // Please, check if it's "else if" or it's a real "if" if (FastqFile3.isEmpty()||input3.equals("Unknown")||input3.equals("")){ setStatus(status_BadRequirements,"No FastqFile pair-end found."); return false; } */ // Please, check if it's "else if" or it's a real "if" if (FastqFile4.isEmpty() || input4.equals("Unknown") || input4.equals("")) { setStatus(status_BadRequirements, Util.BRTypeFile("FastqFile")); return false; } // Test docker Var presence if (Docker.areDockerVariablesNotInProperties(properties)) { setStatus(status_BadRequirements, Util.BRDockerVariables()); return false; } // Extract Docker Variables String doOutputs = properties.get("DockerOutputs"); String doInputs = properties.get("DockerInputs"); // Prepare ouputs output1 = specificPath + File.separator + "OutputOf_" + input4 + ".sam"; outputInDo1 = doOutputs + "OutputOf_" + input4 + ".sam"; output1 = Util.onlyOneOutputOf(output1); outputInDo1 = Util.onlyOneOutputOf(outputInDo1); // Prepare shared folders String[] allInputsPath = { inputPath1, inputPath2, inputPath3, inputPath4 }; String[] simpleId = { inputId1, inputId2, inputId3, inputId4 }; sharedFolders = Docker.createSharedFolders(allInputsPath, simpleId, doInputs); sharedFolders = Docker.addInSharedFolder(sharedFolders, Util.getCanonicalPath(specificPath), doOutputs); // Prepare inputs HashMap<String, String> pathAndArg = new HashMap<String, String>(); pathAndArg.put(inputPath1, ""); pathAndArg.put(inputPath2, ""); pathAndArg.put(inputPath3, ""); pathAndArg.put(inputPath4, ""); allDoInputs = Docker.createAllDockerInputs(pathAndArg, allInputsPath, simpleId, doInputs); // Prepare cluster relations Cluster.createLinkDockerClusterInputs(properties, allInputsPath, simpleId, doInputs); Cluster.createLinkDockerClusterOutput(properties, output1, outputInDo1); // DOCKER INIT if (Docker.isDockerHere()) { long duration = Docker.prepareContainer(properties, sharedFolders); if (!Docker.isDockerContainerIDPresentIn(properties)) { setStatus(status_BadRequirements, Util.BRDockerInit()); return false; } setStatus(status_running, Util.RUNDockerDuration("launch", duration)); } else if (!Cluster.isClusterEnable()) { setStatus(status_BadRequirements, Util.BRDockerNotFound()); return false; } return true; }
From source file:edu.umn.cs.spatialHadoop.mapred.SpatialRecordReader.java
/** * Reads all shapes left in the current block in one shot. This function * runs a loop where it keeps reading shapes by calling the method * {@link #nextShape(Shape)} until one of the following conditions happen. * 1. The whole file is read. No more records to read. * 2. Number of parsed records reaches the threshold defined by the * configuration parameter spatialHadoop.mapred.MaxShapesPerRead. * To disable this check, set the configuration parameter to -1 * 3. Total size of parsed data from file reaches the threshold defined by * the configuration parameter spatialHadoop.mapred.MaxBytesPerRead. * To disable this check, set the configuration parameter to -1. * // w w w. ja v a 2 s . com * @param shapes * @return * @throws IOException */ protected boolean nextShapes(ArrayWritable shapes) throws IOException { // Prepare a vector that will hold all objects in this Vector<Shape> vshapes = new Vector<Shape>(); try { Shape stockObject = (Shape) shapes.getValueClass().newInstance(); // Reached the end of this split if (getFilePosition() >= end) return false; long initialReadPos = getPos(); long readBytes = 0; // Read all shapes in this block while ((maxShapesInOneRead <= 0 || vshapes.size() < maxShapesInOneRead) && (maxBytesInOneRead <= 0 || readBytes < maxBytesInOneRead) && nextShape(stockObject)) { vshapes.add(stockObject.clone()); readBytes = getPos() - initialReadPos; } // Store them in the return value shapes.set(vshapes.toArray(new Shape[vshapes.size()])); return !vshapes.isEmpty(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (OutOfMemoryError e) { LOG.error("Error reading shapes. Stopped with " + vshapes.size() + " shapes"); throw e; } return false; }