Dataset Viewer (First 5GB)
Auto-converted to Parquet
text
stringlengths
240
2.92M
meta
dict
/* Copyright 2010 Semantic Discovery, Inc. (www.semanticdiscovery.com) This file is part of the Semantic Discovery Toolkit. The Semantic Discovery Toolkit is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The Semantic Discovery Toolkit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with The Semantic Discovery Toolkit. If not, see <http://www.gnu.org/licenses/>. */ package org.sd.atn; import java.io.Writer; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import org.sd.io.FileUtil; import org.sd.util.InputContext; import org.sd.util.MathUtil; import org.sd.atn.extract.Extraction; import org.sd.util.MathUtil; import org.sd.util.tree.Tree; import org.sd.util.tree.Tree2Dot; import org.sd.xml.DomContext; /** * Utility class for building html parse output. * <p> * @author Spence Koehler */ public class HtmlParseOutput { private File tempDir; private Set<String> extractionTypes; private boolean filterInterps; private StringBuilder output; public HtmlParseOutput() { this(null, null, false); } public HtmlParseOutput(File tempDir, String extractionTypes, boolean filterInterps) { this.tempDir = tempDir; this.extractionTypes = null; if (extractionTypes != null && !"".equals(extractionTypes.trim())) { this.extractionTypes = new HashSet<String>(); final String[] types = extractionTypes.split(","); for (String type : types) this.extractionTypes.add(type); } this.filterInterps = filterInterps; this.output = new StringBuilder(); } public void addExtractionGroups(ExtractionGroups extractionGroups, boolean briefResults) { if (extractionGroups == null) return; if (briefResults) { output.append("<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"font-size: 80%;\">\n"); output.append(" <tr><th>group</th><th>text</th><th>interp</th><th>label</th><th>conf</th><th>path</th></tr>\n"); extractionGroups.visitExtractions( null, true, new ExtractionGroups.ExtractionVisitor() { ExtractionContainer.ExtractionData priorExtraction = null; public boolean visitExtractionGroup(String source, int groupNum, String groupKey, ExtractionGroup group) { return true; } public void visitInterpretation(String source, int groupNum, String groupKey, ExtractionContainer.ExtractionData theExtraction, int interpNum, ParseInterpretation theInterpretation, String extractionKey) { if (addBriefExtraction(groupNum, groupKey, theExtraction, interpNum, theInterpretation, extractionKey, priorExtraction)) { priorExtraction = theExtraction; } } }); output.append("</table>\n"); } else { for (ExtractionGroup extractionGroup : extractionGroups.getExtractionGroups()) { openExtractionGroup(extractionGroup); for (ExtractionContainer extractionContainer : extractionGroup.getExtractions()) { addExtractionContainer(extractionContainer); } closeExtractionGroup(); } } } public String getOutput() { final StringBuilder result = new StringBuilder(); result. append("<div>\n"). append(output). append("</div>\n"); return result.toString(); } private final void openExtractionGroup(ExtractionGroup extractionGroup) { output. append("<div>\n"). append(" <div>").append(extractionGroup.getKey()).append(" </div>\n"). append(" <table border=\"1\">\n"); } private final void closeExtractionGroup() { output. append(" </table>\n"). append("</div>\n"); } private final boolean addBriefExtraction(int groupNum, String groupKey, ExtractionContainer.ExtractionData theExtraction, int interpNum, ParseInterpretation theInterpretation, String extractionKey, ExtractionContainer.ExtractionData priorExtraction) { if (filterInterps && interpNum > 0) return false; if (extractionTypes != null) { final String extractionType = theExtraction.getExtraction().getType(); if (!extractionTypes.contains(extractionType)) return false; } // ignore consecutive duplicates if (priorExtraction != null) { final Tree<String> priorParseTree = priorExtraction.getParseTree(); final Tree<String> curParseTree = theExtraction.getParseTree(); if (curParseTree.equals(priorParseTree)) return false; } final String parsedText = theExtraction.getParsedText(); output. append("<tr>\n"). append("<td>").append(groupKey).append("</td>\n"). append("<td>").append(getParsedTextHtml(theExtraction)).append("</td>\n"). append("<td>").append(interpNum).append("</td>\n"). append("<td>").append(theInterpretation.getClassification()).append("</td>\n"). append("<td>").append(MathUtil.doubleString(theInterpretation.getConfidence(), 6)).append("</td>\n"). append("<td>").append(extractionKey).append("</td>\n"). append("</tr>\n"); return true; } private String getParsedTextHtml(ExtractionContainer.ExtractionData theExtraction) { if (theExtraction == null) return "???"; final String parsedText = theExtraction.getParsedText(); final StringBuilder result = new StringBuilder(); if (tempDir != null) { final Tree2Dot<String> tree2dot = new Tree2Dot<String>(theExtraction.getParseTree()); tree2dot.setNodeAttribute("fontsize", "8"); File dotFile = null; File dotPng = null; try { dotFile = File.createTempFile("parse.", ".dot", tempDir); final Writer writer = FileUtil.getWriter(dotFile); tree2dot.writeDot(writer); writer.close(); } catch (IOException e) { System.err.println(new Date() + ": WARNING: Unable to convert parseTree to dotFile '" + dotFile + "'!"); e.printStackTrace(System.err); dotFile = null; } if (dotFile != null) { // <a href='webex/genParseGraph.jsp?dotFile=tmp/....dot' target='parseTree'>parsedText</a> result. append("<a href='genParseGraph.jsp?dotFile="). append(dotFile.getName()). append("' target='parseTree'>"). append(parsedText). append("</a>"); dotFile.deleteOnExit(); } } if (result.length() == 0) { result.append(parsedText); } return result.toString(); } private final void addExtractionContainer(ExtractionContainer extractionContainer) { final int curOutputLength = output.length(); openParseResult(extractionContainer.getGlobalStartPosition()); boolean addedOne = false; final ParseInterpretation theInterpretation = extractionContainer.getTheInterpretation(); if (theInterpretation != null) { addedOne = addExtractionData(extractionContainer.getTheExtraction(), extractionContainer.getTheInterpretation()); } else { for (ExtractionContainer.ExtractionData extractionData : extractionContainer.getExtractions()) { addedOne |= addExtractionData(extractionData, null); } } if (!addedOne) { output.setLength(curOutputLength); } else { closeParseResult(); } } private final void openParseResult(int globalStartPos) { output.append("<tr>\n"); } private final void closeParseResult() { output.append("</tr>\n"); } private final boolean addExtractionData(ExtractionContainer.ExtractionData extractionData, ParseInterpretation theInterpretation) { if (extractionData == null) return false; openParse(true, extractionData.getParseNum()); addParseContext(extractionData.getParsedText(), extractionData.getStartPos(), extractionData.getEndPos(), extractionData.getLength(), extractionData.getContext().getInputContext()); addParseExtraction(extractionData.getExtraction()); output.append("<td><table border=\"1\">\n"); // open parseInterpretations if (theInterpretation != null) { output.append('\n'); addParseInterpretation(theInterpretation, 1); } else if (extractionData.getInterpretations() != null && extractionData.getInterpretations().size() > 0) { output.append('\n'); int interpNum = 1; for (ParseInterpretation interpretation : extractionData.getInterpretations()) { addParseInterpretation(interpretation, interpNum++); } } output.append("</table></td>\n"); // close parseInterpretations closeParse(); return true; } private final void addParseContext(String parsedText, int startIndex, int endIndex, int length, InputContext inputContext) { output.append("<td>").append(parsedText).append("</td>\n"); output.append("<td>").append(startIndex).append("</td>\n"); output.append("<td>").append(endIndex).append("</td>\n"); output.append("<td>").append(length).append("</td>\n"); String key = ""; if (inputContext != null && inputContext instanceof DomContext) { final DomContext domContext = (DomContext)inputContext; key = domContext.getIndexedPathString(); } output.append("<td>").append(key).append("</td>\n"); } private final void addParseExtraction(Extraction extraction) { if (extraction == null) return; output.append("<td><table>\n"); doAddParseExtraction(extraction); output.append("</table></td>\n"); } private final void doAddParseExtraction(Extraction extraction) { if (extraction == null) return; output. append("<tr><td align=\"top\">").append(extraction.getType()).append(':').append("</td>\n"). append("<td>\n"); if (extraction.hasFields()) { output.append("<table>\n"); for (List<Extraction> fieldExtractions : extraction.getFields().values()) { if (fieldExtractions != null) { for (Extraction fieldExtraction : fieldExtractions) { doAddParseExtraction(fieldExtraction); } } } output.append("</table>\n"); } else { output.append(extraction.getText()); } output.append("</td>\n"); } private final void addParseInterpretation(ParseInterpretation interpretation, int interpNum) { output.append("<tr><td>").append(interpretation.getClassification()).append("</td>\n"); final double confidence = interpretation.getConfidence(); final String cString = MathUtil.doubleString(confidence, 6); output.append("<td>").append(cString).append("</td>\n"); output.append("<td>").append(interpretation.getToStringOverride()).append("</td>\n"); output.append("</tr>\n"); } private final void openParse(boolean isSelected, int parseNum) { output.append("<td>"); if (isSelected) output.append("*"); output.append("</td><td>").append(parseNum).append("</td>\n"); } private final void closeParse() { } }
{ "task_name": "lcc" }
/* * Copyright 2016 IKS Gesellschaft fuer Informations- und Kommunikationssysteme mbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.iksgmbh.sql.pojomemodb.dataobjects.persistent; import com.iksgmbh.sql.pojomemodb.SQLKeyWords; import com.iksgmbh.sql.pojomemodb.dataobjects.temporal.ApartValue; import com.iksgmbh.sql.pojomemodb.dataobjects.temporal.ColumnInitData; import com.iksgmbh.sql.pojomemodb.dataobjects.temporal.OrderCondition; import com.iksgmbh.sql.pojomemodb.dataobjects.temporal.WhereCondition; import org.junit.Before; import org.junit.Test; import java.math.BigDecimal; import java.sql.SQLDataException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import static org.junit.Assert.*; public class TableTest { private Table sut; @Before public void setup() throws SQLDataException { sut = new Table("Test"); } @Test public void returnsDataWhenAsterixAndAliasAreUsedInCombination() throws SQLDataException { // arrange sut.createNewColumn(createColumnInitData("ID", "Number(5)"), null); sut.createNewColumn(createColumnInitData("Name", "VARCHAR(10)"), null); sut.createNewColumn(createColumnInitData("Date", "Date"), null); final List<ApartValue> values = new ArrayList<ApartValue>(); ApartValue value = new ApartValue("to_date('15.05.16','DD.MM.RR')", "Date"); values.add(value); value = new ApartValue("'Jim'", "Name"); values.add(value); value = new ApartValue("1", "ID"); values.add(value); sut.insertDataRow(values); // act final List<Object[]> result = sut.select(null, new ArrayList<WhereCondition>(), new ArrayList<OrderCondition>()); // assert assertEquals("number of datasets", 1, result.size()); } @Test public void applies_to_char_function() throws SQLDataException { // arrange sut.createNewColumn(createColumnInitData("Column1", "Date"), null); final List<ApartValue> values = new ArrayList<ApartValue>(); ApartValue value = new ApartValue("to_date('15.05.16','DD.MM.RR')", "Column1"); values.add(value); sut.insertDataRow(values); final List<String> selectedColumns = new ArrayList<String>(); selectedColumns.add("to_char(Column1, 'dd.mm.yyyy hh24:mi:ss')"); final List<WhereCondition> whereConditions = new ArrayList<WhereCondition>(); // act final List<Object[]> result = sut.select(selectedColumns, whereConditions, new ArrayList<OrderCondition>()); // assert final String dateAsString = (String) result.get(0)[0]; System.err.println("<" + dateAsString + ">"); assertEquals("date value", "15.05.2016 00:00:00", dateAsString); } @Test public void buildsCloneOfDataRows() throws SQLDataException { // arrange sut.createNewColumn(createColumnInitData("Column1", "Date"), null); sut.createNewColumn(createColumnInitData("Column2", "varchar(50)"), null); sut.createNewColumn(createColumnInitData("Column3", "Number(10,2)"), null); final List<ApartValue> values = new ArrayList<ApartValue>(); values.add(new ApartValue("to_date('15.05.16','DD.MM.RR')", "Column1")); values.add(new ApartValue("'Test'", "Column2")); values.add(new ApartValue("10.2", "Column3")); sut.insertDataRow(values); // act 1 final List<Object[]> result1 = sut.createDataRowsClone(); result1.get(0)[0] = null; result1.get(0)[1] = "New"; result1.get(0)[2] = BigDecimal.ZERO; // act 2 final List<Object[]> result2 = sut.createDataRowsClone(); // assert assertEquals("number value", "10.2", ((BigDecimal)result2.get(0)[2]).toPlainString() ); assertEquals("text value", "Test", result2.get(0)[1]); assertEquals("date value", "Sun May 15 00:00:00 CEST 2016", result2.get(0)[0].toString()); } @Test public void ordersNullValues() throws SQLException { // arrange test table sut.createNewColumn(createColumnInitData("Column1", "Date"), null); sut.createNewColumn(createColumnInitData("Column2", "varchar(50)"), null); sut.createNewColumn(createColumnInitData("Column3", "Number(10,2)"), null); List<ApartValue> values = new ArrayList<ApartValue>(); values.add(new ApartValue("to_date('15.05.16','DD.MM.RR')", "Column1")); values.add(new ApartValue("'NotNull'", "Column2")); values.add(new ApartValue("10.2", "Column3")); sut.insertDataRow(values); // column 2 is NOT null values = new ArrayList<ApartValue>(); values.add(new ApartValue("to_date('15.05.16','DD.MM.RR')", "Column1")); values.add(new ApartValue("10.2", "Column3")); sut.insertDataRow(values); // column 2 is null // arrange select statement data final List<String> columns = new ArrayList<String>(); columns.add("Column2"); final List<OrderCondition> orderConditions = new ArrayList<OrderCondition>(); orderConditions.add(new OrderCondition("Column2", SQLKeyWords.ASC)); // act 1 final List<Object[]> result1 = sut.select(columns, new ArrayList<WhereCondition>(), orderConditions); // act 2 orderConditions.clear(); orderConditions.add(new OrderCondition("Column2", SQLKeyWords.DESC)); final List<Object[]> result2 = sut.select(columns, new ArrayList<WhereCondition>(), orderConditions); // assert assertNull(result1.get(0)[0]); assertEquals("Column2", "NotNull", result1.get(1)[0]); assertEquals("Column2", "NotNull", result2.get(0)[0]); assertNull(result2.get(1)[0]); } @Test public void usesDefaultValueIfDefined() throws SQLDataException { // arrange sut.createNewColumn(createColumnInitData("Column_With_Default", "VARCHAR(20)", "'DefaultValue'", null), null); sut.createNewColumn(createColumnInitData("Column_No_Default", "Date"), null); sut.createNewColumn(createColumnInitData("DateColumn", "Date", "sysdate", null), null); sut.createNewColumn(createColumnInitData("ID", "NUMBER"), null); final List<ApartValue> values = new ArrayList<ApartValue>(); values.add(new ApartValue("1", "ID")); // act sut.insertDataRow(values); // assert final List<Object[]> result = sut.createDataRowsClone(); assertEquals("value of ColumnWithDefault", "DefaultValue", result.get(0)[0]); assertNull(result.get(0)[1]); assertNotNull(result.get(0)[2]); } @Test public void throwsExceptionForDuplicatesInPrimaryKeyColumn() throws SQLDataException { // arrange sut.createNewColumn(createColumnInitData("Column_With_Default", "VARCHAR(20)", "'DefaultValue'", null), null); sut.createNewColumn(createColumnInitData("Column_No_Default", "Date"), null); sut.createNewColumn(createColumnInitData("DateColumn", "Date", "sysdate", null), null); sut.createNewColumn(createColumnInitData("ID", "NUMBER", null, "primaryKeyId"), null); final List<ApartValue> values = new ArrayList<ApartValue>(); values.add(new ApartValue("1", "ID")); sut.insertDataRow(values); // act try { sut.insertDataRow(values); fail("Expected exception was not thrown!"); } catch (SQLDataException e) { // assert assertEquals("Error message", "Primary Key Constraint violated in column 'ID' with value '1'.", e.getMessage().trim()); } } private ColumnInitData createColumnInitData(String colName, String colType) { ColumnInitData toReturn = new ColumnInitData(colName); toReturn.columnType = colType; return toReturn; } private ColumnInitData createColumnInitData(String colName, String colType, String defaultValue, String primKey) { ColumnInitData toReturn = createColumnInitData(colName, colType); toReturn.defaultValue = defaultValue; toReturn.primaryKey = primKey; return toReturn; } }
{ "task_name": "lcc" }
/******************************************************************************* * * Pentaho Data Integration * * Copyright (C) 2002-2012 by Pentaho : http://www.pentaho.com * ******************************************************************************* * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ package org.pentaho.di.job.entries.ssh2put; import static org.pentaho.di.job.entry.validator.AndValidator.putValidators; import static org.pentaho.di.job.entry.validator.JobEntryValidatorUtils.andValidator; import static org.pentaho.di.job.entry.validator.JobEntryValidatorUtils.fileExistsValidator; import static org.pentaho.di.job.entry.validator.JobEntryValidatorUtils.integerValidator; import static org.pentaho.di.job.entry.validator.JobEntryValidatorUtils.notBlankValidator; import static org.pentaho.di.job.entry.validator.JobEntryValidatorUtils.notNullValidator; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileType; import org.pentaho.di.cluster.SlaveServer; import org.pentaho.di.core.CheckResultInterface; import org.pentaho.di.core.Const; import org.pentaho.di.core.Result; import org.pentaho.di.core.database.DatabaseMeta; import org.pentaho.di.core.encryption.Encr; import org.pentaho.di.core.exception.KettleDatabaseException; import org.pentaho.di.core.exception.KettleException; import org.pentaho.di.core.exception.KettleFileException; import org.pentaho.di.core.exception.KettleXMLException; import org.pentaho.di.core.vfs.KettleVFS; import org.pentaho.di.core.xml.XMLHandler; import org.pentaho.di.i18n.BaseMessages; import org.pentaho.di.job.JobMeta; import org.pentaho.di.job.entries.ssh2get.FTPUtils; import org.pentaho.di.job.entry.JobEntryBase; import org.pentaho.di.job.entry.JobEntryInterface; import org.pentaho.di.repository.ObjectId; import org.pentaho.di.repository.Repository; import org.pentaho.di.resource.ResourceEntry; import org.pentaho.di.resource.ResourceReference; import org.pentaho.di.resource.ResourceEntry.ResourceType; import org.w3c.dom.Node; import com.trilead.ssh2.Connection; import com.trilead.ssh2.HTTPProxyData; import com.trilead.ssh2.KnownHosts; import com.trilead.ssh2.SFTPv3Client; import com.trilead.ssh2.SFTPv3FileAttributes; import com.trilead.ssh2.SFTPv3FileHandle; /** * This defines a SSH2 Put job entry. * * @author Samatar * @since 17-12-2007 * */ public class JobEntrySSH2PUT extends JobEntryBase implements Cloneable, JobEntryInterface { private static Class<?> PKG = JobEntrySSH2PUT.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$ private String serverName; private String userName; private String password; private String serverPort; private String ftpDirectory; private String localDirectory; private String wildcard; private boolean onlyGettingNewFiles; /* Don't overwrite files */ private boolean usehttpproxy; private String httpproxyhost; private String httpproxyport; private String httpproxyusername; private String httpProxyPassword; private boolean publicpublickey; private String keyFilename; private String keyFilePass; private boolean useBasicAuthentication; private boolean createRemoteFolder; private String afterFtpPut; private String destinationfolder; private boolean createDestinationFolder; private boolean cachehostkey; private int timeout; static KnownHosts database = new KnownHosts(); public JobEntrySSH2PUT(String n) { super(n, ""); serverName=null; publicpublickey=false; keyFilename=null; keyFilePass=null; usehttpproxy=false; httpproxyhost=null; httpproxyport=null; httpproxyusername=null; httpProxyPassword=null; serverPort="22"; useBasicAuthentication=false; createRemoteFolder=false; afterFtpPut="do_nothing"; destinationfolder=null; createDestinationFolder=false; cachehostkey=false; timeout=0; setID(-1L); } public JobEntrySSH2PUT() { this(""); } public Object clone() { JobEntrySSH2PUT je = (JobEntrySSH2PUT) super.clone(); return je; } public String getXML() { StringBuffer retval = new StringBuffer(128); retval.append(super.getXML()); retval.append(" ").append(XMLHandler.addTagValue("servername", serverName)); retval.append(" ").append(XMLHandler.addTagValue("username", userName)); retval.append(" ").append(XMLHandler.addTagValue("password", Encr.encryptPasswordIfNotUsingVariables(getPassword()))); retval.append(" ").append(XMLHandler.addTagValue("serverport", serverPort)); retval.append(" ").append(XMLHandler.addTagValue("ftpdirectory", ftpDirectory)); retval.append(" ").append(XMLHandler.addTagValue("localdirectory", localDirectory)); retval.append(" ").append(XMLHandler.addTagValue("wildcard", wildcard)); retval.append(" ").append(XMLHandler.addTagValue("only_new", onlyGettingNewFiles)); retval.append(" ").append(XMLHandler.addTagValue("usehttpproxy", usehttpproxy)); retval.append(" ").append(XMLHandler.addTagValue("httpproxyhost", httpproxyhost)); retval.append(" ").append(XMLHandler.addTagValue("httpproxyport", httpproxyport)); retval.append(" ").append(XMLHandler.addTagValue("httpproxyusername", httpproxyusername)); retval.append(" ").append(XMLHandler.addTagValue("httpproxypassword", httpProxyPassword)); retval.append(" ").append(XMLHandler.addTagValue("publicpublickey", publicpublickey)); retval.append(" ").append(XMLHandler.addTagValue("keyfilename", keyFilename)); retval.append(" ").append(XMLHandler.addTagValue("keyfilepass", keyFilePass)); retval.append(" ").append(XMLHandler.addTagValue("usebasicauthentication", useBasicAuthentication)); retval.append(" ").append(XMLHandler.addTagValue("createremotefolder", createRemoteFolder)); retval.append(" ").append(XMLHandler.addTagValue("afterftpput", afterFtpPut)); retval.append(" ").append(XMLHandler.addTagValue("destinationfolder", destinationfolder)); retval.append(" ").append(XMLHandler.addTagValue("createdestinationfolder", createDestinationFolder)); retval.append(" ").append(XMLHandler.addTagValue("cachehostkey", cachehostkey)); retval.append(" ").append(XMLHandler.addTagValue("timeout", timeout)); return retval.toString(); } public void loadXML(Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep) throws KettleXMLException { try { super.loadXML(entrynode, databases, slaveServers); serverName = XMLHandler.getTagValue(entrynode, "servername"); userName = XMLHandler.getTagValue(entrynode, "username"); password = Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(entrynode, "password")); serverPort = XMLHandler.getTagValue(entrynode, "serverport"); ftpDirectory = XMLHandler.getTagValue(entrynode, "ftpdirectory"); localDirectory = XMLHandler.getTagValue(entrynode, "localdirectory"); wildcard = XMLHandler.getTagValue(entrynode, "wildcard"); onlyGettingNewFiles = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "only_new") ); usehttpproxy = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "usehttpproxy") ); httpproxyhost = XMLHandler.getTagValue(entrynode, "httpproxyhost"); httpproxyport = XMLHandler.getTagValue(entrynode, "httpproxyport"); httpproxyusername = XMLHandler.getTagValue(entrynode, "httpproxyusername"); httpProxyPassword = XMLHandler.getTagValue(entrynode, "httpproxypassword"); publicpublickey = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "publicpublickey") ); keyFilename = XMLHandler.getTagValue(entrynode, "keyfilename"); keyFilePass = XMLHandler.getTagValue(entrynode, "keyfilepass"); useBasicAuthentication = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "usebasicauthentication") ); createRemoteFolder = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "createremotefolder") ); afterFtpPut = XMLHandler.getTagValue(entrynode, "afterftpput"); destinationfolder = XMLHandler.getTagValue(entrynode, "destinationfolder"); createDestinationFolder = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "createdestinationfolder") ); cachehostkey = "Y".equalsIgnoreCase( XMLHandler.getTagValue(entrynode, "cachehostkey") ); timeout = Const.toInt(XMLHandler.getTagValue(entrynode, "timeout"), 0); } catch(KettleXMLException xe) { throw new KettleXMLException(BaseMessages.getString(PKG, "JobSSH2PUT.Log.UnableLoadXML", xe.getMessage())); } } public void loadRep(Repository rep, ObjectId id_jobentry, List<DatabaseMeta> databases, List<SlaveServer> slaveServers) throws KettleException { try { serverName = rep.getJobEntryAttributeString(id_jobentry, "servername"); userName = rep.getJobEntryAttributeString(id_jobentry, "username"); password = Encr.decryptPasswordOptionallyEncrypted( rep.getJobEntryAttributeString(id_jobentry, "password") ); serverPort =rep.getJobEntryAttributeString(id_jobentry, "serverport"); ftpDirectory = rep.getJobEntryAttributeString(id_jobentry, "ftpdirectory"); localDirectory = rep.getJobEntryAttributeString(id_jobentry, "localdirectory"); wildcard = rep.getJobEntryAttributeString(id_jobentry, "wildcard"); onlyGettingNewFiles = rep.getJobEntryAttributeBoolean(id_jobentry, "only_new"); usehttpproxy = rep.getJobEntryAttributeBoolean(id_jobentry, "usehttpproxy"); httpproxyhost = rep.getJobEntryAttributeString(id_jobentry, "httpproxyhost"); httpproxyusername = rep.getJobEntryAttributeString(id_jobentry, "httpproxyusername"); httpProxyPassword = rep.getJobEntryAttributeString(id_jobentry, "httpproxypassword"); publicpublickey = rep.getJobEntryAttributeBoolean(id_jobentry, "publicpublickey"); keyFilename = rep.getJobEntryAttributeString(id_jobentry, "keyfilename"); keyFilePass = rep.getJobEntryAttributeString(id_jobentry, "keyfilepass"); useBasicAuthentication = rep.getJobEntryAttributeBoolean(id_jobentry, "usebasicauthentication"); createRemoteFolder = rep.getJobEntryAttributeBoolean(id_jobentry, "createremotefolder"); afterFtpPut = rep.getJobEntryAttributeString(id_jobentry, "afterftpput"); destinationfolder = rep.getJobEntryAttributeString(id_jobentry, "destinationfolder"); createDestinationFolder = rep.getJobEntryAttributeBoolean(id_jobentry, "createdestinationfolder"); cachehostkey = rep.getJobEntryAttributeBoolean(id_jobentry, "cachehostkey"); timeout = (int)rep.getJobEntryAttributeInteger(id_jobentry, "timeout"); } catch(KettleException dbe) { throw new KettleException(BaseMessages.getString(PKG, "JobSSH2PUT.Log.UnableLoadRep",""+id_jobentry,dbe.getMessage())); } } public void saveRep(Repository rep, ObjectId id_job) throws KettleException { try { rep.saveJobEntryAttribute(id_job, getObjectId(), "servername", serverName); rep.saveJobEntryAttribute(id_job, getObjectId(), "username", userName); rep.saveJobEntryAttribute(id_job, getObjectId(), "password", Encr.encryptPasswordIfNotUsingVariables(password)); rep.saveJobEntryAttribute(id_job, getObjectId(), "serverport", serverPort); rep.saveJobEntryAttribute(id_job, getObjectId(), "ftpdirectory", ftpDirectory); rep.saveJobEntryAttribute(id_job, getObjectId(), "localdirectory", localDirectory); rep.saveJobEntryAttribute(id_job, getObjectId(), "wildcard", wildcard); rep.saveJobEntryAttribute(id_job, getObjectId(), "only_new", onlyGettingNewFiles); rep.saveJobEntryAttribute(id_job, getObjectId(), "usehttpproxy", usehttpproxy); rep.saveJobEntryAttribute(id_job, getObjectId(), "httpproxyhost", httpproxyhost); rep.saveJobEntryAttribute(id_job, getObjectId(), "httpproxyport", httpproxyport); rep.saveJobEntryAttribute(id_job, getObjectId(), "httpproxyusername", httpproxyusername); rep.saveJobEntryAttribute(id_job, getObjectId(), "httpproxypassword", httpProxyPassword); rep.saveJobEntryAttribute(id_job, getObjectId(), "publicpublickey", publicpublickey); rep.saveJobEntryAttribute(id_job, getObjectId(), "keyfilename", keyFilename); rep.saveJobEntryAttribute(id_job, getObjectId(), "keyfilepass", keyFilePass); rep.saveJobEntryAttribute(id_job, getObjectId(), "usebasicauthentication", useBasicAuthentication); rep.saveJobEntryAttribute(id_job, getObjectId(), "createremotefolder", createRemoteFolder); rep.saveJobEntryAttribute(id_job, getObjectId(), "afterftpput", afterFtpPut); rep.saveJobEntryAttribute(id_job, getObjectId(), "destinationfolder", destinationfolder); rep.saveJobEntryAttribute(id_job, getObjectId(), "createdestinationfolder", createDestinationFolder); rep.saveJobEntryAttribute(id_job, getObjectId(), "cachehostkey", cachehostkey); rep.saveJobEntryAttribute(id_job, getObjectId(), "timeout", timeout); } catch(KettleDatabaseException dbe) { throw new KettleException(BaseMessages.getString(PKG, "JobSSH2PUT.Log.UnableSaveRep",""+id_job,dbe.getMessage())); } } /** * @return Returns the directory. */ public String getFtpDirectory() { return ftpDirectory; } /** * @param directory The directory to set. */ public void setFtpDirectory(String directory) { this.ftpDirectory = directory; } /** * @return Returns the password. */ public String getPassword() { return password; } /** * @param password The password to set. */ public void setPassword(String password) { this.password = password; } /** * @return Returns The action to do after transfer */ public String getAfterFTPPut() { return afterFtpPut; } /** * @param afterFtpPut The action to do after transfer */ public void setAfterFTPPut(String afterFtpPut) { this.afterFtpPut = afterFtpPut; } /** * @param httpProxyPassword The HTTP proxy password to set. */ public void setHTTPProxyPassword(String httpProxyPassword) { this.httpProxyPassword = httpProxyPassword; } /** * @return Returns the password. */ public String getHTTPProxyPassword() { return httpProxyPassword; } /** * @param keyFilePass The key file pass to set. */ public void setKeyFilepass(String keyFilePass) { this.keyFilePass = keyFilePass; } /** * @return Returns the key file pass. */ public String getKeyFilepass() { return keyFilePass; } /** * @return Returns the serverName. */ public String getServerName() { return serverName; } /** * @param serverName The serverName to set. */ public void setServerName(String serverName) { this.serverName = serverName; } /** * @param proxyhost The httpproxyhost to set. */ public void setHTTPProxyHost(String proxyhost) { this.httpproxyhost = proxyhost; } /** * @return Returns the httpproxyhost. */ public String getHTTPProxyHost() { return httpproxyhost; } /** * @param keyFilename The key filename to set. */ public void setKeyFilename(String keyFilename) { this.keyFilename = keyFilename; } /** * @return Returns the key filename. */ public String getKeyFilename() { return keyFilename; } /** * @return Returns the userName. */ public String getUserName() { return userName; } /** * @param userName The userName to set. */ public void setUserName(String userName) { this.userName = userName; } /** * @param proxyusername The httpproxyusername to set. */ public void setHTTPProxyUsername(String proxyusername) { this.httpproxyusername = proxyusername; } /** * @return Returns the userName. */ public String getHTTPProxyUsername() { return httpproxyusername; } /** * @return Returns the wildcard. */ public String getWildcard() { return wildcard; } /** * @param wildcard The wildcard to set. */ public void setWildcard(String wildcard) { this.wildcard = wildcard; } /** * @return Returns the localDirectory. */ public String getlocalDirectory() { return localDirectory; } /** * @param localDirectory The localDirectory to set. */ public void setlocalDirectory(String localDirectory) { this.localDirectory = localDirectory; } /** * @return Returns the onlyGettingNewFiles. */ public boolean isOnlyGettingNewFiles() { return onlyGettingNewFiles; } /** * @param onlyGettingNewFiles The onlyGettingNewFiles to set. */ public void setOnlyGettingNewFiles(boolean onlyGettingNewFiles) { this.onlyGettingNewFiles = onlyGettingNewFiles; } /** * @param cachehostkeyin The cachehostkey to set. */ public void setCacheHostKey(boolean cachehostkeyin) { this.cachehostkey = cachehostkeyin; } /** * @return Returns the cachehostkey. */ public boolean isCacheHostKey() { return cachehostkey; } /** * @param httpproxy The usehttpproxy to set. */ public void setUseHTTPProxy(boolean httpproxy) { this.usehttpproxy = httpproxy; } /** * @return Returns the usehttpproxy. */ public boolean isUseHTTPProxy() { return usehttpproxy; } /** * @return Returns the usebasicauthentication. */ public boolean isUseBasicAuthentication() { return useBasicAuthentication; } /** * @param useBasicAuthenticationin The use basic authentication flag to set. */ public void setUseBasicAuthentication(boolean useBasicAuthenticationin) { this.useBasicAuthentication = useBasicAuthenticationin; } /** * @param createRemoteFolder The create remote folder flag to set. */ public void setCreateRemoteFolder(boolean createRemoteFolder) { this.createRemoteFolder = createRemoteFolder; } /** * @return Returns the create remote folder flag. */ public boolean isCreateRemoteFolder() { return createRemoteFolder; } /** * @param createDestinationFolder The create destination folder flag to set. */ public void setCreateDestinationFolder(boolean createDestinationFolder) { this.createDestinationFolder = createDestinationFolder; } /** * @return Returns the create destination folder flag */ public boolean isCreateDestinationFolder() { return createDestinationFolder; } /** * @param publickey The publicpublickey to set. */ public void setUsePublicKey(boolean publickey) { this.publicpublickey = publickey; } /** * @return Returns the usehttpproxy. */ public boolean isUsePublicKey() { return publicpublickey; } public String getServerPort() { return serverPort; } public void setServerPort(String serverPort) { this.serverPort = serverPort; } public void setHTTPProxyPort(String proxyport) { this.httpproxyport = proxyport; } public String getHTTPProxyPort() { return httpproxyport; } public void setDestinationFolder(String destinationfolderin) { this.destinationfolder = destinationfolderin; } public String getDestinationFolder() { return destinationfolder; } /** * @param timeout The timeout to set. */ public void setTimeout(int timeout) { this.timeout = timeout; } /** * @return Returns the timeout. */ public int getTimeout() { return timeout; } public Result execute(Result previousResult, int nr) { Result result = previousResult; result.setResult( false ); try { // Get real variable value String realServerName=environmentSubstitute(serverName); int realServerPort=Const.toInt(environmentSubstitute(serverPort),22); String realUserName=environmentSubstitute(userName); String realServerPassword=Encr.decryptPasswordOptionallyEncrypted(environmentSubstitute(password)); // Proxy Host String realProxyHost=environmentSubstitute(httpproxyhost); int realProxyPort=Const.toInt(environmentSubstitute(httpproxyport),22); String realproxyUserName=environmentSubstitute(httpproxyusername); String realProxyPassword=Encr.decryptPasswordOptionallyEncrypted(environmentSubstitute(httpProxyPassword)); // Key file String realKeyFilename=environmentSubstitute(keyFilename); String relKeyFilepass=environmentSubstitute(keyFilePass); // Source files String realLocalDirectory=environmentSubstitute(localDirectory); String realwildcard=environmentSubstitute(wildcard); // Remote destination String realftpDirectory=environmentSubstitute(ftpDirectory); // Destination folder (Move to) String realDestinationFolder=environmentSubstitute(destinationfolder); try{ // Remote source realftpDirectory=FTPUtils.normalizePath(realftpDirectory); // Destination folder (Move to) realDestinationFolder=FTPUtils.normalizePath(realDestinationFolder); }catch(Exception e){ logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.CanNotNormalizePath",e.getMessage())); result.setNrErrors(1); return result; } // Check for mandatory fields boolean mandatoryok=true; if(Const.isEmpty(realServerName)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.ServernameMissing")); } if(usehttpproxy) { if(Const.isEmpty(realProxyHost)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.HttpProxyhostMissing")); } } if(publicpublickey) { if(Const.isEmpty(realKeyFilename)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.KeyFileMissing")); }else { // Let's check if folder exists... if(!KettleVFS.fileExists(realKeyFilename, this)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.KeyFileNotExist")); } } } if(Const.isEmpty(realLocalDirectory)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.LocalFolderMissing")); } if(afterFtpPut.equals("move_file")) { if(Const.isEmpty(realDestinationFolder)) { mandatoryok=false; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.DestinatFolderMissing")); }else{ FileObject folder=null; try{ folder=KettleVFS.getFileObject(realDestinationFolder, this); // Let's check if folder exists... if(!folder.exists()) { // Do we need to create it? if(createDestinationFolder) folder.createFolder(); else logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.DestinatFolderNotExist",realDestinationFolder)); } }catch(Exception e){throw new KettleException(e);} finally { if(folder!=null) { try{ folder.close(); folder=null; }catch(Exception e){}; } } } } if(mandatoryok) { Connection conn = null; SFTPv3Client client = null; boolean good=true; int nbfilestoput=0; int nbput=0; int nbrerror=0; try { // Create a connection instance conn = getConnection(realServerName,realServerPort,realProxyHost,realProxyPort,realproxyUserName,realProxyPassword); if(timeout>0){ // Use timeout // Cache Host Key if(cachehostkey) conn.connect(new SimpleVerifier(database),0,timeout*1000); else conn.connect(null,0,timeout*1000); }else{ // Cache Host Key if(cachehostkey) conn.connect(new SimpleVerifier(database)); else conn.connect(); } // Authenticate boolean isAuthenticated = false; if(publicpublickey){ String keyContent = KettleVFS.getTextFileContent(realKeyFilename, this, Const.XML_ENCODING); isAuthenticated=conn.authenticateWithPublicKey(realUserName, keyContent.toCharArray(), relKeyFilepass); }else{ isAuthenticated=conn.authenticateWithPassword(realUserName, realServerPassword); } // LET'S CHECK AUTHENTICATION ... if (isAuthenticated == false) logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.AuthenticationFailed")); else { if(log.isBasic()) logBasic(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Connected",serverName,userName)); client = new SFTPv3Client(conn); if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.ProtocolVersion",""+client.getProtocolVersion())); // Check if remote directory exists if(!Const.isEmpty(realftpDirectory)) { if (!sshDirectoryExists(client, realftpDirectory)) { good=false; if(createRemoteFolder) { good=CreateRemoteFolder(client,realftpDirectory); if(good) logBasic(BaseMessages.getString(PKG, "JobSSH2PUT.Log.RemoteDirectoryCreated")); } else logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.RemoteDirectoryNotExist",realftpDirectory)); } else if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.RemoteDirectoryExist",realftpDirectory)); } if (good) { // Get files list from local folder (source) List<FileObject> myFileList = getFiles(realLocalDirectory); // Prepare Pattern for wildcard Pattern pattern = null; if (!Const.isEmpty(realwildcard)) pattern = Pattern.compile(realwildcard); // Let's put files now ... // Get the files in the list for (int i=0;i<myFileList.size() && !parentJob.isStopped();i++) { FileObject myFile = myFileList.get(i); String localFilename = myFile.toString(); String remoteFilename = myFile.getName().getBaseName(); boolean getIt = true; // First see if the file matches the regular expression! if (pattern!=null){ Matcher matcher = pattern.matcher(remoteFilename); getIt = matcher.matches(); } // do we have a target directory? if(!Const.isEmpty(realftpDirectory)) remoteFilename=realftpDirectory + FTPUtils.FILE_SEPARATOR +remoteFilename; if(onlyGettingNewFiles) { // We get only new files // ie not exist on the remote server getIt=!sshFileExists(client, remoteFilename); } if(getIt) { nbfilestoput++; boolean putok=putFile(myFile, remoteFilename, client); if(!putok) { nbrerror++; logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.CanNotPutFile",localFilename)); }else{ nbput++; } if(putok && !afterFtpPut.equals("do_nothing")){ deleteOrMoveFiles(myFile,realDestinationFolder); } } } /********************************RESULT ********************/ if(log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Result.JobEntryEnd1")); logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Result.TotalFiles",""+nbfilestoput)); logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Result.TotalFilesPut",""+nbput)); logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Result.TotalFilesError",""+nbrerror)); logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Result.JobEntryEnd2")); } if(nbrerror==0) result.setResult(true); /********************************RESULT ********************/ } } } catch (Exception e) { result.setNrErrors(nbrerror); logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.ErrorFTP",e.getMessage())); } finally { if (conn!=null) conn.close(); if(client!=null) client.close(); } } } catch(Exception e) { result.setResult(false); result.setNrErrors(1L); logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.UnexpectedError"), e); } return result; } private Connection getConnection(String servername,int serverport, String proxyhost,int proxyport,String proxyusername,String proxypassword) { /* Create a connection instance */ Connection connect = new Connection(servername,serverport); /* We want to connect through a HTTP proxy */ if(usehttpproxy) { connect.setProxyData(new HTTPProxyData(proxyhost, proxyport)); /* Now connect */ // if the proxy requires basic authentication: if(useBasicAuthentication) { connect.setProxyData(new HTTPProxyData(proxyhost, proxyport, proxyusername, proxypassword)); } } return connect; } private boolean putFile(FileObject localFile, String remotefilename, SFTPv3Client sftpClient) { long filesize=-1; InputStream in = null; BufferedInputStream inBuf = null; SFTPv3FileHandle sftpFileHandle=null; boolean retval=false; try { // Put file in the folder sftpFileHandle=sftpClient.createFileTruncate(remotefilename); // Associate a file input stream for the current local file in = KettleVFS.getInputStream(localFile); inBuf = new BufferedInputStream(in); byte[] buf = new byte[2048]; long offset = 0; long length = localFile.getContent().getSize(); if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.SendingFile",localFile.toString() ,""+length,remotefilename)); // Write to remote file while(true){ int len = in.read(buf, 0, buf.length); if(len <= 0) break; sftpClient.write(sftpFileHandle, offset, buf, 0, len); offset += len; } // Get File size filesize=getFileSize(sftpClient, remotefilename) ; if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.FileOnRemoteHost", remotefilename,""+filesize)); retval= true; } catch(Exception e) { // We failed to put files logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.ErrorCopyingFile",localFile.toString())+":"+e.getMessage()); } finally { if (in != null) { try { in.close(); in = null; } catch (Exception ex) {} } if(inBuf!=null) { try { inBuf.close(); inBuf = null; } catch (Exception ex) {} } if(sftpFileHandle!=null) { try { sftpClient.closeFile(sftpFileHandle); sftpFileHandle=null; } catch (Exception ex) {} } } return retval; } /** * Check existence of a file * * @param sftpClient * @param filename * @return true, if file exists * @throws Exception */ public boolean sshFileExists(SFTPv3Client sftpClient, String filename) { try { SFTPv3FileAttributes attributes = sftpClient.stat(filename); if (attributes != null) { return (attributes.isRegularFile()); } else { return false; } } catch (Exception e) { return false; } } /** * Checks if a directory exists * * @param sftpClient * @param directory * @return true, if directory exists */ public boolean sshDirectoryExists(SFTPv3Client sftpClient, String directory) { try { SFTPv3FileAttributes attributes = sftpClient.stat(directory); if (attributes != null) { return (attributes.isDirectory()); } else { return false; } } catch (Exception e) { return false; } } /** * Create remote folder * * @param sftpClient * @param foldername * @return true, if foldername is created */ private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername) { boolean retval=false; if(!sshDirectoryExists(sftpClient, foldername)) { try { sftpClient.mkdir(foldername, 0700); retval=true; }catch (Exception e) { logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.CreatingRemoteFolder",foldername)); } } return retval; } /** * Returns the file size of a file * * @param sftpClient * @param filename * @return the size of the file * @throws Exception */ public long getFileSize(SFTPv3Client sftpClient, String filename) throws Exception { return sftpClient.stat(filename).size.longValue(); } private List<FileObject> getFiles(String localfolder) throws KettleFileException { try { List<FileObject> myFileList = new ArrayList<FileObject>(); // Get all the files in the local directory... FileObject localFiles = KettleVFS.getFileObject(localfolder, this); FileObject[] children = localFiles.getChildren(); if (children!=null) { for (int i=0; i<children.length; i++) { // Get filename of file or directory if (children[i].getType().equals(FileType.FILE)) { myFileList.add(children[i]); } } // end for } return myFileList; } catch(IOException e) { throw new KettleFileException(e); } } private boolean deleteOrMoveFiles(FileObject file, String destinationFolder) throws KettleException { try { boolean retval=false; // Delete the file if this is needed! // if (afterFtpPut.equals("delete_file")) { file.delete(); retval=true; if (log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.DeletedFile",file.toString())); } else if (afterFtpPut.equals("move_file")) { // Move File FileObject destination=null; FileObject source=null; try { destination = KettleVFS.getFileObject(destinationFolder + Const.FILE_SEPARATOR + file.getName().getBaseName(), this); file.moveTo(destination); retval=true; } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobSSH2PUT.Cant_Move_File.Label",file.toString(),destinationFolder,e.getMessage())); } finally { if ( destination != null ) {try {destination.close();}catch (Exception ex ) {};} if ( source != null ) {try {source.close();} catch (Exception ex ) {}; } } if (log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2PUT.Log.MovedFile",file.toString(),ftpDirectory)); } return retval; } catch(Exception e) { throw new KettleException(e); } } public boolean evaluates() { return true; } public List<ResourceReference> getResourceDependencies(JobMeta jobMeta) { List<ResourceReference> references = super.getResourceDependencies(jobMeta); if (!Const.isEmpty(serverName)) { String realServerName = jobMeta.environmentSubstitute(serverName); ResourceReference reference = new ResourceReference(this); reference.getEntries().add( new ResourceEntry(realServerName, ResourceType.SERVER)); references.add(reference); } return references; } @Override public void check(List<CheckResultInterface> remarks, JobMeta jobMeta) { andValidator().validate(this, "serverName", remarks, putValidators(notBlankValidator())); //$NON-NLS-1$ andValidator() .validate(this, "localDirectory", remarks, putValidators(notBlankValidator(), fileExistsValidator())); //$NON-NLS-1$ andValidator().validate(this, "userName", remarks, putValidators(notBlankValidator())); //$NON-NLS-1$ andValidator().validate(this, "password", remarks, putValidators(notNullValidator())); //$NON-NLS-1$ andValidator().validate(this, "serverPort", remarks, putValidators(integerValidator())); //$NON-NLS-1$ } }
{ "task_name": "lcc" }
Passage 1: Bianca Moon Bianca Moon( born 14 December) is an Australian songwriter, actress and activist. Moon trained at the National Institute of Dramatic Art, Australian Theatre for Young People, Screenwise and the Australian Institute of Music. She gained exposure early on in her career for her exceptional ability as a songwriter and producer. Her close friend is Katherine Kelly Lang. In 2013 Both Lang and Moon were nominated for their first Emmy Awards. Lang for acting and Moon for outstanding original song. Moon is only the second Australian to be nominated for a Daytime Emmy and is also the youngest person ever to be nominated for a technical Emmy Award. Passage 2: Willem Brakman Willem Pieter Jacobus Brakman( 1922 – 2008) was a Dutch writer who made his literary debut with the novel" Een winterreis" in 1961. Brakman received the P. C. Hooft Award in 1980. He was born on June 13th, 1922 in The Hague, Netherlands, and died on May 8th, 2008 in the same country. Passage 3: Sun and Moon Bay railway station Sun and Moon Bay railway station is a railway station of Hainan East Ring Intercity Rail located at Sun and Moon Bay, near Wanning, Hainan, China. Passage 4: Sun and Moon Bay Sun and Moon Bay, also known as Riyue Bay, is located approximately 25 km south of Wanning, Hainan, China. It is around 4.5 km long, and has been the site of numerous surfing events. The" Sun and Moon Bay Haimen Tourism Area" is located here. The Sun and Moon Bay Railway Station will be situated approximately 1 km inland from this bay. Passage 5: Eight Thousand Li of Cloud and Moon Eight Thousand Li of Cloud and Moon may refer to: Passage 6: Godwin Davy Godwin Davy( born 15 December 1979) is an Anguillan international footballer who plays as a goalkeeper. He made his international debut in a World Cup qualifying match against El Salvador, resulting in a lopsided match, losing 12- 0 in February 2008, and also played in the 4 – 0 loss to the same country in the return match in March 2008. Passage 7: Emiliano Purita Emiliano Purita( born 25 March 1997) is an Argentine professional footballer who plays as a midfielder for San Martín, on loan from San Lorenzo. Passage 8: Lillie (Pokémon) Lillie is a character in the 2016 video game" Pokémon Sun" and" Moon", of which she is regarded as the central character. Passage 9: Moon Hyang-ja Moon Hyang- Ja( born May 5, 1972) is a South Korean team handball player and Olympic champion. She received a gold medal with the Korean team at the 1992 Summer Olympics in Barcelona. She received a silver medal at the 1996 Summer Olympics in Atlanta. Passage 10: 2001–02 UEFA Champions League second group stage Eight winners and eight runners- up from the first group stage were drawn into four groups of four teams, each containing two group winners and two runners- up. Teams from the same country or from the same first round group could not be drawn together. The top two teams in each group advanced to the quarter- finals. Question: Are Emiliano Purita and Moon Hyang-Ja both from the same country? Answer: no
{ "task_name": "2WikiMultihopQA" }
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Analyzer.Utilities; using Analyzer.Utilities.Extensions; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.NetAnalyzers; using Microsoft.CodeAnalysis.Operations; namespace Microsoft.NetCore.Analyzers.Runtime { using static MicrosoftNetCoreAnalyzersResources; /// <summary> /// CA1307: Specify StringComparison /// </summary> [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] public sealed class SpecifyStringComparisonAnalyzer : AbstractGlobalizationDiagnosticAnalyzer { private const string RuleId_CA1307 = "CA1307"; private const string RuleId_CA1310 = "CA1310"; private static readonly ImmutableArray<string> s_CA1310MethodNamesWithFirstStringParameter = ImmutableArray.Create("Compare", "StartsWith", "EndsWith", "IndexOf", "LastIndexOf"); internal static readonly DiagnosticDescriptor Rule_CA1307 = DiagnosticDescriptorHelper.Create( RuleId_CA1307, CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1307Title)), CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1307Message)), DiagnosticCategory.Globalization, RuleLevel.Disabled, description: CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1307Description)), isPortedFxCopRule: true, isDataflowRule: false); internal static readonly DiagnosticDescriptor Rule_CA1310 = DiagnosticDescriptorHelper.Create( RuleId_CA1310, CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1310Title)), CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1310Message)), DiagnosticCategory.Globalization, RuleLevel.IdeHidden_BulkConfigurable, description: CreateLocalizableResourceString(nameof(SpecifyStringComparisonCA1310Description)), isPortedFxCopRule: false, isDataflowRule: false); public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Rule_CA1307, Rule_CA1310); protected override void InitializeWorker(CompilationStartAnalysisContext context) { var stringComparisonType = context.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemStringComparison); var stringType = context.Compilation.GetSpecialType(SpecialType.System_String); // Without these symbols the rule cannot run if (stringComparisonType == null) { return; } var overloadMap = GetWellKnownStringOverloads(context.Compilation, stringType, stringComparisonType); var linqExpressionType = context.Compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemLinqExpressionsExpression1); context.RegisterOperationAction(oaContext => { var invocationExpression = (IInvocationOperation)oaContext.Operation; var targetMethod = invocationExpression.TargetMethod; if (targetMethod.IsGenericMethod || targetMethod.ContainingType == null || targetMethod.ContainingType.IsErrorType()) { return; } // Check if we are in a Expression<Func<T...>> context, in which case it is possible // that the underlying call doesn't have the comparison option so we want to bail-out. if (invocationExpression.IsWithinExpressionTree(linqExpressionType)) { return; } // Report correctness issue CA1310 for known string comparison methods that default to culture specific string comparison: // https://docs.microsoft.com/dotnet/standard/base-types/best-practices-strings#string-comparisons-that-use-the-current-culture if (targetMethod.ContainingType.SpecialType == SpecialType.System_String && !overloadMap.IsEmpty && overloadMap.ContainsKey(targetMethod)) { ReportDiagnostic( Rule_CA1310, oaContext, invocationExpression, targetMethod, overloadMap[targetMethod]); return; } // Report maintainability issue CA1307 for any method that has an additional overload with the exact same parameter list, // plus as additional StringComparison parameter. Default StringComparison may or may not match user's intent, // but it is recommended to explicitly specify it for clarity and readability: // https://docs.microsoft.com/dotnet/standard/base-types/best-practices-strings#recommendations-for-string-usage IEnumerable<IMethodSymbol> methodsWithSameNameAsTargetMethod = targetMethod.ContainingType.GetMembers(targetMethod.Name).OfType<IMethodSymbol>(); if (methodsWithSameNameAsTargetMethod.HasMoreThan(1)) { var correctOverload = methodsWithSameNameAsTargetMethod .GetMethodOverloadsWithDesiredParameterAtTrailing(targetMethod, stringComparisonType) .FirstOrDefault(); if (correctOverload != null) { ReportDiagnostic( Rule_CA1307, oaContext, invocationExpression, targetMethod, correctOverload); } } }, OperationKind.Invocation); static ImmutableDictionary<IMethodSymbol, IMethodSymbol> GetWellKnownStringOverloads( Compilation compilation, INamedTypeSymbol stringType, INamedTypeSymbol stringComparisonType) { var objectType = compilation.GetSpecialType(SpecialType.System_Object); var booleanType = compilation.GetSpecialType(SpecialType.System_Boolean); var integerType = compilation.GetSpecialType(SpecialType.System_Int32); var stringCompareToNamedMethods = stringType.GetMembers("CompareTo").OfType<IMethodSymbol>(); var stringCompareToParameterString = stringCompareToNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(stringType)); var stringCompareToParameterObject = stringCompareToNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(objectType)); var stringCompareNamedMethods = stringType.GetMembers("Compare").OfType<IMethodSymbol>(); var stringCompareParameterStringStringBool = stringCompareNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(stringType), GetParameterInfo(stringType), GetParameterInfo(booleanType)); var stringCompareParameterStringStringStringComparison = stringCompareNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(stringType), GetParameterInfo(stringType), GetParameterInfo(stringComparisonType)); var stringCompareParameterStringIntStringIntIntBool = stringCompareNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(stringType), GetParameterInfo(integerType), GetParameterInfo(stringType), GetParameterInfo(integerType), GetParameterInfo(integerType), GetParameterInfo(booleanType)); var stringCompareParameterStringIntStringIntIntComparison = stringCompareNamedMethods.GetFirstOrDefaultMemberWithParameterInfos( GetParameterInfo(stringType), GetParameterInfo(integerType), GetParameterInfo(stringType), GetParameterInfo(integerType), GetParameterInfo(integerType), GetParameterInfo(stringComparisonType)); var overloadMapBuilder = ImmutableDictionary.CreateBuilder<IMethodSymbol, IMethodSymbol>(); overloadMapBuilder.AddKeyValueIfNotNull(stringCompareToParameterString, stringCompareParameterStringStringStringComparison); overloadMapBuilder.AddKeyValueIfNotNull(stringCompareToParameterObject, stringCompareParameterStringStringStringComparison); overloadMapBuilder.AddKeyValueIfNotNull(stringCompareParameterStringStringBool, stringCompareParameterStringStringStringComparison); overloadMapBuilder.AddKeyValueIfNotNull(stringCompareParameterStringIntStringIntIntBool, stringCompareParameterStringIntStringIntIntComparison); foreach (var methodName in s_CA1310MethodNamesWithFirstStringParameter) { var methodsWithMethodName = stringType.GetMembers(methodName).OfType<IMethodSymbol>(); foreach (var method in methodsWithMethodName) { if (!method.Parameters.IsEmpty && method.Parameters[0].Type.SpecialType == SpecialType.System_String && !method.Parameters[^1].Type.Equals(stringComparisonType)) { var recommendedMethod = methodsWithMethodName .GetMethodOverloadsWithDesiredParameterAtTrailing(method, stringComparisonType) .FirstOrDefault(); if (recommendedMethod != null) { overloadMapBuilder.AddKeyValueIfNotNull(method, recommendedMethod); } } } } return overloadMapBuilder.ToImmutable(); } } private static void ReportDiagnostic( DiagnosticDescriptor rule, OperationAnalysisContext oaContext, IInvocationOperation invocationExpression, IMethodSymbol targetMethod, IMethodSymbol correctOverload) { oaContext.ReportDiagnostic( invocationExpression.CreateDiagnostic( rule, targetMethod.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat), oaContext.ContainingSymbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat), correctOverload.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat))); } private static ParameterInfo GetParameterInfo(INamedTypeSymbol type, bool isArray = false, int arrayRank = 0, bool isParams = false) { return ParameterInfo.GetParameterInfo(type, isArray, arrayRank, isParams); } } }
{ "task_name": "lcc" }
Passage 1: Marian Shields Robinson Marian Lois Robinson( née Shields; born July 29, 1937) is the mother of Michelle Obama, former First Lady of the United States, and Craig Robinson, a basketball executive, and the mother- in- law of former U.S. President Barack Obama. Passage 2: Priscilla Pointer Priscilla Marie Pointer( born May 18, 1924) is an American stage, film and television character actress. She began her career in the theater, including productions on Broadway. Later, Pointer moved to Hollywood to act in films and on television. She is the mother of Amy Irving, therefore making her the former mother- in- law of filmmakers Steven Spielberg and Bruno Barreto and the mother- in- law of documentary filmmaker Kenneth Bowser, Jr. Passage 3: Maureen Reagan Maureen Elizabeth Reagan (January 4, 1941 – August 8, 2001) was an American political activist, the first child of U.S. President Ronald Reagan and his first wife, actress Jane Wyman. Her adoptive brother was Michael Reagan and her half-siblings were Patti Davis and Ron Reagan, from her father's second marriage (to Nancy Davis). Passage 4: Vera Miletić Vera Miletić (Serbian Cyrillic: Вера Милетић; 8 March 1920 – 7 September 1944) was a Serbian student and soldier. She was notable for being the mother of Mira Marković, posthumously making her the mother-in-law of Serbian president Slobodan Milošević. Passage 5: Baroness Gösta von dem Bussche-Haddenhausen Baroness Gösta von dem Bussche- Haddenhausen( 26 January 1902 – 13 June 1996) was the mother of Prince Claus of the Netherlands, who was the Prince Consort of Queen Beatrix of the Netherlands, thus making her the mother- in- law of the former Dutch Queen. She is also the paternal grandmother of King Willem- Alexander of the Netherlands, who is the current Dutch King. Passage 6: Maria Thins Maria Thins( c. 1593 – 27 December 1680) was the mother- in- law of Johannes Vermeer and a member of the Gouda Thins family. Passage 7: David Sills David George Sills (March 21, 1938 – August 23, 2011) was an American jurist. Sills served as the presiding justice for the California Court of Appeal for the Fourth Appellate District, Division Three. He is a former mayor of Irvine, California, the largest planned city in the United States. From 1964 to 1968, Sills was married to Maureen Reagan, the daughter of U.S. President Ronald Reagan. He was a member of the Republican State Central Committee of California from 1966 to 1968 and Chairman of the Republican Associates of Orange County from 1968 to 1969. Sills was appointed as a judge to California's Superior Court in 1985 by Governor George Deukmejian and served there until being promoted to be the Presiding Justice at the Court of Appeal again by Governor Deukmejian in 1990, where he served with distinction and exemplary leadership. He authored approximately 2,400 legal opinions. He received a B.S. from Bradley University in 1959 and his legal degree from the University of Illinois College of Law in 1961. Prior to being named to the bench he served in the U.S. Marine Corps between 1960 and 1965, reaching the rank of captain. He had a private law practice in Orange County, California between 1965 and 1985 and was an elected member of the Irvine City Council between 1976 and 1985, serving as mayor for four years during that period. During his tenure he worked with the Council to responsibly manage the rapid growth Irvine was experiencing at the time. Sills was also the Irvine Health Foundation's founding Chairman and remained for 26 years. During his service over $25 Million was granted to philanthropic organizations in Orange County to improve health issues for those in need. Prior to developing knee problems, Sills was a marathon runner who often competed in the Boston Marathon. He enjoyed wood working and had a full range of tools and machines in his garage, fondly known as the "Sills Cabinet Shop. " Sills had an extensive library at his Irvine home and studied history and politics. Passage 8: Ebba Eriksdotter Vasa Ebba Eriksdotter Vasa (circa 1491 – 21 November 1549) was a Swedish noblewoman. She was the mother of Queen Margaret Leijonhufvud and the second cousin and mother-in-law of King Gustav Vasa. Passage 9: Eldon Howard Eldon Howard was a British screenwriter. She was the mother- in- law of Edward J. Danziger and wrote a number of the screenplays for films by his company Danziger Productions. Passage 10: Cornelia (mother of the Gracchi) Cornelia( c. 190s – c. 115 BC) was the second daughter of Publius Cornelius Scipio Africanus, the hero of the Second Punic War, and Aemilia Paulla. She is remembered as a prototypical example of a virtuous Roman woman. She was the mother of the Gracchi brothers, and the mother- in- law of Scipio Aemilianus. Question: Who is David Sills's mother-in-law? Answer: Jane Wyman
{ "task_name": "2WikiMultihopQA" }
package net.craftstars.general.util; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import com.ensifera.animosity.craftirc.CommandEndPoint; import com.ensifera.animosity.craftirc.CraftIRC; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.SimpleCommandMap; import org.bukkit.configuration.Configuration; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import net.craftstars.general.General; import net.craftstars.general.command.CommandBase; import net.craftstars.general.text.LanguageText; public final class CommandManager { public static boolean setAliases = false; private static SimpleCommandMap commandMap = null; private static Map<String,Command> knownCommands = null; private static Method register = null; public static String[] compassAliases; public static String[] posAliases; public static HashMap<CommandEndPoint, String> cmdTags = null; private CommandManager() {} public static void setup(Configuration config) { if(setAliases) return; getCommandMap(); if(!config.getKeys(false).contains("aliases")) General.logger.warn(LanguageText.LOG_COMMAND_NO_ALIASES.value()); Plugin chat = Bukkit.getPluginManager().getPlugin("CraftIRC"); boolean foundIRC = isCraftIRC3(chat); PluginDescriptionFile plug = General.plugin.getDescription(); try { Map<String,Map<String,Object>> commands = plug.getCommands(); for(String key : commands.keySet()) { PluginCommand generalCommand = General.plugin.getCommand(key); //General.logger.debug("Registering aliases for command: " + key); try { Class<? extends CommandBase> clazz = General.class.getClassLoader() .loadClass("net.craftstars.general.command." + generalCommand.getName() + "Command") .asSubclass(CommandBase.class); CommandBase commandInstance = clazz.getConstructor(General.class, Command.class) .newInstance(General.plugin, generalCommand); generalCommand.setExecutor(commandInstance); if(foundIRC) { if(cmdTags == null) cmdTags = new HashMap<CommandEndPoint, String>(); CraftIRC irc = (CraftIRC) chat; String tag = generalCommand.getLabel(); try { CommandEndPoint ep = commandInstance.new CraftIRCForwarder(irc, tag); cmdTags.put(ep, tag); } catch(Exception e) { General.logger.warn(LanguageText.LOG_COMMAND_IRC_REG_ERROR.value("command", generalCommand.getName())); } } } catch(ClassNotFoundException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(IllegalArgumentException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(SecurityException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(InstantiationException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(IllegalAccessException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(InvocationTargetException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } catch(NoSuchMethodException e) { General.logger.error(LanguageText.LOG_COMMAND_REG_ERROR.value("command", generalCommand.getName()),e); } if(register != null && key.contains(".")) register(key.split("\\.")[1], generalCommand); if(knownCommands != null) { Iterator<Entry<String,Command>> iter = knownCommands.entrySet().iterator(); while(iter.hasNext()) { Entry<String,Command> cmd = iter.next(); if(cmd.getValue() != generalCommand) continue; cmd.setValue(new GeneralCommand(generalCommand)); } } List<String> aliases = config.getStringList("aliases." + key); if(aliases == null) { //General.logger.warn("No aliases defined for " + key + " command; skipping."); continue; } for(String alias : aliases) register(alias, generalCommand); } } catch(NullPointerException e) { e.printStackTrace(); return; } catch(ClassCastException e) { General.logger.error("Commands are of wrong type!",e); } } private static boolean isCraftIRC3(Plugin irc) { if(irc != null && irc instanceof CraftIRC && irc.getDescription().getVersion().startsWith("3")) return true; return false; } public static boolean register(String label, Command command) { try { boolean success = (Boolean) register.invoke(commandMap, label, "General.dynalias", command, true); if(!success) { Command cmd = Bukkit.getPluginCommand(label); String claimant; if(cmd instanceof PluginCommand) claimant = ((PluginCommand) cmd).getPlugin().getDescription().getName(); else claimant = Bukkit.getName(); General.logger.info(LanguageText.LOG_COMMAND_TAKEN.value("alias", label, "plugin", claimant)); } return success; } catch(IllegalArgumentException e) { General.logger.warn(e.getMessage()); } catch(IllegalAccessException e) { General.logger.warn(e.getMessage()); } catch(InvocationTargetException e) { General.logger.warn(e.getMessage()); } return false; } @SuppressWarnings("unchecked") private static boolean getCommandMap() { CraftServer cs = (CraftServer) Bukkit.getServer(); Field cm; try { cm = CraftServer.class.getDeclaredField("commandMap"); } catch(SecurityException e) { General.logger.warn(e.getMessage()); return false; } catch(NoSuchFieldException e) { General.logger.warn(e.getMessage()); return false; } cm.setAccessible(true); try { commandMap = (SimpleCommandMap) cm.get(cs); } catch(IllegalArgumentException e) { General.logger.warn(e.getMessage()); return false; } catch(IllegalAccessException e) { General.logger.warn(e.getMessage()); return false; } if(commandMap == null) return false; try { register = SimpleCommandMap.class.getDeclaredMethod("register", String.class, String.class, Command.class, boolean.class); } catch(SecurityException e) { General.logger.warn(e.getMessage()); return false; } catch(NoSuchMethodException e) { General.logger.warn(e.getMessage()); return false; } register.setAccessible(true); try { Field commands = SimpleCommandMap.class.getDeclaredField("knownCommands"); commands.setAccessible(true); knownCommands = (Map<String,Command>)commands.get(commandMap); } catch(SecurityException e) { return false; } catch(NoSuchFieldException e) { General.logger.warn(e.getMessage()); return false; } catch(IllegalArgumentException e) { General.logger.warn(e.getMessage()); return false; } catch(IllegalAccessException e) { General.logger.warn(e.getMessage()); return false; } return true; } public static class GeneralCommand extends Command { private PluginCommand command; public GeneralCommand(PluginCommand cmd) { super(cmd.getName(), cmd.getDescription(), cmd.getUsage(), cmd.getAliases()); command = cmd; } @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { return command.execute(sender, commandLabel, args); } @Override public String getName() { return command.getName(); } @Override public String getPermission() { return command.getPermission(); } @Override public void setPermission(String permission) { command.setPermission(permission); } @Override public boolean testPermission(CommandSender target) { return command.testPermission(target); } @Override public boolean testPermissionSilent(CommandSender target) { return command.testPermissionSilent(target); } @Override public String getLabel() { return command.getLabel(); } @Override public boolean setLabel(String name) { return command.setLabel(name); } @Override public boolean register(CommandMap map) { return command.register(map); } @Override public boolean unregister(CommandMap map) { return command.unregister(map); } @Override public boolean isRegistered() { return command.isRegistered(); } @Override public List<String> getAliases() { return command.getAliases(); } @Override public String getPermissionMessage() { return command.getPermissionMessage(); } @Override public String getDescription() { return command.getDescription(); } @Override public String getUsage() { return command.getUsage(); } @Override public GeneralCommand setAliases(List<String> aliases) { command.setAliases(aliases); return this; } @Override public GeneralCommand setDescription(String descr) { command.setDescription(descr); return this; } @Override public GeneralCommand setPermissionMessage(String permissionMessage) { command.setPermissionMessage(permissionMessage); return this; } @Override public GeneralCommand setUsage(String usage) { command.setUsage(usage); return this; } public CommandBase getExecutor() { return (CommandBase)command.getExecutor(); } } }
{ "task_name": "lcc" }
Passage 1: Mark J. Sullivan Mark J. Sullivan was the Director of the United States Secret Service from May 31, 2006 to March 27, 2013. Sullivan succeeded W. Ralph Basham and was sworn in as the 22nd Director of the Secret Service on May 31, 2006. He was succeeded by Julia Pierson on March 27, 2013. Passage 2: J. Walter Ruben Jacob Walter Ruben (August 14, 1899 – September 4, 1942) was an American screenwriter, film director and producer. He wrote for 35 films between 1926 and 1942. He also directed 19 films between 1931 and 1940. His great-grandson is actor Hutch Dano. He was born in New York City and died in Hollywood. He is interred at Glendale's Forest Lawn Memorial Park Cemetery. Passage 3: Elmer Washburn Elmer Washburn was the 3rd Director of the United States Secret Service. Passage 4: Olav Aaraas Olav Aaraas( born 10 July 1950) is a Norwegian historian and museum director. He was born in Fredrikstad. From 1982 to 1993 he was the director of Sogn Folk Museum, from 1993 to 2010 he was the director of Maihaugen and from 2001 he has been the director of the Norwegian Museum of Cultural History. In 2010 he was decorated with the Royal Norwegian Order of St. Olav. Passage 5: Ian Barry (director) Ian Barry is an Australian director of film and TV. Passage 6: Peter Levin Peter Levin is an American director of film, television and theatre. Passage 7: William P. Wood William Patrick Wood (March 11, 1820 – March 20, 1903) was the first Director of the United States Secret Service. He was the son of James Wood and Margaret Turner. He was sworn in on July 5, 1865 by Secretary of the Treasury Hugh McCulloch. He then headed the newly formed Secret Service for four years until he resigned in 1869. Wood was a veteran of the Mexican–American War and was once Keeper of the Old Capitol Prison. He was considered the best in battling financial crime, and within a year of its founding, the Secret Service had arrested over 200 counterfeiters. He died on March 20, 1903, and was buried in the Congressional Cemetery in Washington, D.C. Passage 8: Secret Service (1931 film) Secret Service is a 1931 American Pre-Code drama film directed by J. Walter Ruben and written by Bernard Schubert. The film based on a play by William Gillette, stars Richard Dix, Shirley Grey, and Nance O'Neil. The film was released on November 14, 1931, by RKO Pictures. Passage 9: U. E. Baughman Urbanus Edmund Baughman( 21 May 1905 – 6 November 1978) was the chief of the United States Secret Service between 1948 and 1961, under Presidents Truman, Eisenhower, and Kennedy. Baughman was the first Secret Service Chief to pen a memoir concerning the office he held. Entitled" Secret Service Chief", it was a veritable tell- all on the intricacies and inner workings of the Secret Service and its evolution from a counterfeit detection department to the presidential protection unit. Baughman was appointed to head the Secret Service by President Harry S. Truman shortly after the 1948 election. According to the book" American Gunfight", by Stephen Hunter and John Bainbridge Jr., Truman dismissed Baughman's predecessor James J. Maloney in part because he had dispatched most of Truman's Secret Service detail to New York to prepare to guard New York Governor Thomas E. Dewey. Dewey was widely expected to be elected president but was beaten by Truman in one of the greatest upsets in presidential election history. Passage 10: Brian Kennedy (gallery director) Brian Patrick Kennedy( born 5 November 1961) is an Irish- born art museum director who has worked in Ireland and Australia, and now lives and works in the United States. He is currently the director of the Peabody Essex Museum. He was the director of the Toledo Museum of Art in Ohio from 2010 to 2019. He was the director of the Hood Museum of Art from 2005 to 2010, and the National Gallery of Australia( Canberra) from 1997- 2004. Question: Where was the place of death of the director of film Secret Service (1931 Film)? Answer: Hollywood
{ "task_name": "2WikiMultihopQA" }
#pragma warning disable 109, 114, 219, 429, 168, 162 namespace haxe.io { public class Bytes : global::haxe.lang.HxObject { public Bytes(global::haxe.lang.EmptyObject empty) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" { } } #line default } public Bytes(int length, byte[] b) { unchecked { #line 29 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" global::haxe.io.Bytes.__hx_ctor_haxe_io_Bytes(this, length, b); } #line default } public static void __hx_ctor_haxe_io_Bytes(global::haxe.io.Bytes __temp_me34, int length, byte[] b) { unchecked { #line 30 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" __temp_me34.length = length; __temp_me34.b = b; } #line default } public static new object __hx_createEmpty() { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return new global::haxe.io.Bytes(((global::haxe.lang.EmptyObject) (global::haxe.lang.EmptyObject.EMPTY) )); } #line default } public static new object __hx_create(global::Array arr) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return new global::haxe.io.Bytes(((int) (global::haxe.lang.Runtime.toInt(arr[0])) ), ((byte[]) (arr[1]) )); } #line default } public int length; public byte[] b; public override double __hx_setField_f(string field, int hash, double @value, bool handleProperties) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" switch (hash) { case 520590566: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" this.length = ((int) (@value) ); #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return @value; } default: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return base.__hx_setField_f(field, hash, @value, handleProperties); } } } #line default } public override object __hx_setField(string field, int hash, object @value, bool handleProperties) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" switch (hash) { case 98: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" this.b = ((byte[]) (@value) ); #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return @value; } case 520590566: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" this.length = ((int) (global::haxe.lang.Runtime.toInt(@value)) ); #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return @value; } default: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return base.__hx_setField(field, hash, @value, handleProperties); } } } #line default } public override object __hx_getField(string field, int hash, bool throwErrors, bool isCheck, bool handleProperties) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" switch (hash) { case 98: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return this.b; } case 520590566: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return this.length; } default: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return base.__hx_getField(field, hash, throwErrors, isCheck, handleProperties); } } } #line default } public override double __hx_getField_f(string field, int hash, bool throwErrors, bool handleProperties) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" switch (hash) { case 520590566: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return ((double) (this.length) ); } default: { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" return base.__hx_getField_f(field, hash, throwErrors, handleProperties); } } } #line default } public override void __hx_getFields(global::Array<object> baseArr) { unchecked { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" baseArr.push("b"); #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" baseArr.push("length"); #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" { #line 24 "C:\\HaxeToolkit\\haxe\\std/haxe/io/Bytes.hx" base.__hx_getFields(baseArr); } } #line default } } }
{ "task_name": "lcc" }
"The Project Gutenberg EBook of Up and Down, by Edward Frederic Benson\n\nThis eBook is for th(...TRUNCATED)
{ "task_name": "narrativeqa" }
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
30