Java Code Examples for org.apache.commons.compress.utils.Lists#newArrayList()

The following examples show how to use org.apache.commons.compress.utils.Lists#newArrayList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LivyRestExecutor.java    From kylin with Apache License 2.0 6 votes vote down vote up
private List<String> getLogs(JSONObject logInfo) {
    List<String> logs = Lists.newArrayList();
    if (logInfo.has("log")) {
        try {
            JSONArray logArray = logInfo.getJSONArray("log");

            for (int i=0; i<logArray.length(); i++) {
                logs.add(logArray.getString(i));
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return logs;
}
 
Example 2
Source File: TxYunMsgMaker.java    From WePush with MIT License 6 votes vote down vote up
/**
 * 准备(界面字段等)
 */
@Override
public void prepare() {
    templateId = Integer.parseInt(TxYunMsgForm.getInstance().getMsgTemplateIdTextField().getText());

    if (TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        TxYunMsgForm.initTemplateDataTable();
    }

    DefaultTableModel tableModel = (DefaultTableModel) TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
    int rowCount = tableModel.getRowCount();
    paramList = Lists.newArrayList();
    for (int i = 0; i < rowCount; i++) {
        String value = ((String) tableModel.getValueAt(i, 1));
        paramList.add(value);
    }
}
 
Example 3
Source File: WxMaTemplateMsgMaker.java    From WePush with MIT License 6 votes vote down vote up
/**
 * 准备(界面字段等)
 */
@Override
public void prepare() {
    templateId = MaTemplateMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim();
    templateUrl = MaTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim();
    templateKeyWord = MaTemplateMsgForm.getInstance().getMsgTemplateKeyWordTextField().getText().trim() + ".DATA";

    if (MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        MaTemplateMsgForm.initTemplateDataTable();
    }

    DefaultTableModel tableModel = (DefaultTableModel) MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel();
    int rowCount = tableModel.getRowCount();
    TemplateData templateData;
    templateDataList = Lists.newArrayList();
    for (int i = 0; i < rowCount; i++) {
        String name = ((String) tableModel.getValueAt(i, 0)).trim();
        String value = ((String) tableModel.getValueAt(i, 1)).trim();
        String color = ((String) tableModel.getValueAt(i, 2)).trim();
        templateData = new TemplateData();
        templateData.setName(name);
        templateData.setValue(value);
        templateData.setColor(color);
        templateDataList.add(templateData);
    }
}
 
Example 4
Source File: Fx3DVisualizerModule.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public static void setupNew3DVisualizer(final RawDataFile dataFile, final Range<Double> mzRange,
    final Range<Double> rtRange, final Feature featureToShow) {

  final ParameterSet myParameters =
      MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
  final Fx3DVisualizerModule myInstance =
      MZmineCore.getModuleInstance(Fx3DVisualizerModule.class);
  myParameters.getParameter(Fx3DVisualizerParameters.dataFiles)
      .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, new RawDataFile[] {dataFile});
  myParameters.getParameter(Fx3DVisualizerParameters.scanSelection)
      .setValue(new ScanSelection(rtRange, 1));
  myParameters.getParameter(Fx3DVisualizerParameters.mzRange).setValue(mzRange);
  
  List<FeatureSelection> featuresList = Lists.newArrayList();
  if (featureToShow != null) {
    FeatureSelection selectedFeature = new FeatureSelection(null, featureToShow, null, null);
    featuresList.add(selectedFeature);
  }
  
  myParameters.getParameter(Fx3DVisualizerParameters.features).setValue(featuresList);
  if (myParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(),
      true) == ExitCode.OK) {
    myInstance.runModule(MZmineCore.getProjectManager().getCurrentProject(),
        myParameters.cloneParameterSet(), new ArrayList<Task>());
  }
}
 
Example 5
Source File: OLAPWindowRel.java    From kylin with Apache License 2.0 6 votes vote down vote up
ColumnRowType buildColumnRowType() {
    OLAPRel olapChild = (OLAPRel) getInput(0);
    ColumnRowType inputColumnRowType = olapChild.getColumnRowType();

    List<TblColRef> columns = new ArrayList<>();
    // the input col always be collected by left
    columns.addAll(inputColumnRowType.getAllColumns());

    // add window aggregate calls column
    for (Group group : groups) {
        List<TupleExpression> sourceColOuter = Lists.newArrayList();
        group.keys.asSet().stream().map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add);
        group.orderKeys.getFieldCollations().stream().map(RelFieldCollation::getFieldIndex)
                .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add);
        for (AggregateCall aggrCall : group.getAggregateCalls(this)) {
            TblColRef aggrCallCol = TblColRef.newInnerColumn(aggrCall.getName(),
                    TblColRef.InnerDataTypeEnum.LITERAL);
            List<TupleExpression> sourceColInner = Lists.newArrayList(sourceColOuter.iterator());
            aggrCall.getArgList().stream().filter(i -> i < inputColumnRowType.size())
                    .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColInner::add);
            aggrCallCol.setSubTupleExps(sourceColInner);
            columns.add(aggrCallCol);
        }
    }
    return new ColumnRowType(columns);
}
 
Example 6
Source File: UpYunMsgMaker.java    From WePush with MIT License 6 votes vote down vote up
/**
 * 准备(界面字段等)
 */
@Override
public void prepare() {
    templateId = UpYunMsgForm.getInstance().getMsgTemplateIdTextField().getText();

    if (UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        UpYunMsgForm.initTemplateDataTable();
    }

    DefaultTableModel tableModel = (DefaultTableModel) UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
    int rowCount = tableModel.getRowCount();
    paramList = Lists.newArrayList();
    for (int i = 0; i < rowCount; i++) {
        String value = ((String) tableModel.getValueAt(i, 1));
        paramList.add(value);
    }
}
 
Example 7
Source File: AliyunMsgMaker.java    From WePush with MIT License 6 votes vote down vote up
/**
 * 准备(界面字段等)
 */
@Override
public void prepare() {
    templateId = AliYunMsgForm.getInstance().getMsgTemplateIdTextField().getText();

    if (AliYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        AliYunMsgForm.initTemplateDataTable();
    }

    DefaultTableModel tableModel = (DefaultTableModel) AliYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
    int rowCount = tableModel.getRowCount();
    TemplateData templateData;
    templateDataList = Lists.newArrayList();
    for (int i = 0; i < rowCount; i++) {
        String name = ((String) tableModel.getValueAt(i, 0)).trim();
        String value = ((String) tableModel.getValueAt(i, 1)).trim();
        templateData = new TemplateData();
        templateData.setName(name);
        templateData.setValue(value);
        templateDataList.add(templateData);
    }

}
 
Example 8
Source File: MailMsgSender.java    From WePush with MIT License 5 votes vote down vote up
@Override
public SendResult send(String[] msgData) {
    SendResult sendResult = new SendResult();

    try {
        MailMsg mailMsg = mailMsgMaker.makeMsg(msgData);
        List<String> tos = Lists.newArrayList();
        tos.add(msgData[0]);
        if (PushControl.dryRun) {
            sendResult.setSuccess(true);
            return sendResult;
        } else {
            List<String> ccList = null;
            if (StringUtils.isNotBlank(mailMsg.getMailCc())) {
                ccList = Lists.newArrayList();
                ccList.add(mailMsg.getMailCc());
            }
            if (StringUtils.isEmpty(mailMsg.getMailFiles())) {
                MailUtil.send(mailAccount, tos, ccList, null, mailMsg.getMailTitle(), mailMsg.getMailContent(), true);
            } else {
                MailUtil.send(mailAccount, tos, ccList, null, mailMsg.getMailTitle(), mailMsg.getMailContent(), true, FileUtil.file(mailMsg.getMailFiles()));
            }
            sendResult.setSuccess(true);
        }
    } catch (Exception e) {
        sendResult.setSuccess(false);
        sendResult.setInfo(e.getMessage());
        log.error(ExceptionUtils.getStackTrace(e));
    }

    return sendResult;
}
 
Example 9
Source File: FusionWriter.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
private static List<TransExonRef> parseTransExonRefs(final String data)
{
    List<TransExonRef> transExonRefs = Lists.newArrayList();

    for(String ref : data.split(ITEM_DELIM, -1))
    {
        String[] items = ref.split(":");
        if(items.length != 4)
            continue;

        transExonRefs.add(new TransExonRef(items[0], Integer.parseInt(items[1]), items[2], Integer.parseInt(items[3])));
    }

    return transExonRefs;
}
 
Example 10
Source File: HadoopInputFile.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public String[] getBlockLocations(long start, long end) {
  List<String> hosts = Lists.newArrayList();
  try {
    for (BlockLocation location : fs.getFileBlockLocations(path, start, end)) {
      Collections.addAll(hosts, location.getHosts());
    }

    return hosts.toArray(NO_LOCATION_PREFERENCE);

  } catch (IOException e) {
    throw new RuntimeIOException(e, "Failed to get block locations for path: %s", path);
  }
}
 
Example 11
Source File: ConnectionsDataSerializer.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
@Override
public SingleData<ConnectionsData> serialize(File file) throws IOException {
    ConnectionsDataSet dataSet = reader.read(file);

    final Map<Date, ConnectionsData> stats = dataSet.getSummary();
    final List<Date> periods = Lists.newArrayList(stats.keySet().iterator());
    final List<ConnectionsData> values = Lists.newArrayList(stats.values().iterator());

    SingleData<ConnectionsData> ret = new SingleData<>();

    ret.setPeriods(periods);
    ret.setValues(values);

    return ret;
}
 
Example 12
Source File: CheckoutCommand.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Example command line: {@code tf delete dir/file.txt}
 * <p>
 * Example stdout:<br>
 * <pre>{@code dir:
 * file.txt}</pre>
 * <p>
 * Example stderr:<br>
 * <pre>{@code The item C:\FullPath\dir\file.txt could not be found in your workspace, or you do not have permission to access it.}</pre>
 */
@Override
public TfvcCheckoutResult parseOutput(String stdout, String stderr) {
    List<TfsLocalPath> checkedOutFiles = Lists.newArrayList();
    List<TfsLocalPath> notFoundFiles = Lists.newArrayList();
    List<String> errorMessages = Lists.newArrayList();

    parseStdErr(stderr, notFoundFiles, errorMessages);
    parseStdOut(stdout, checkedOutFiles);

    return new TfvcCheckoutResult(checkedOutFiles, notFoundFiles, errorMessages);
}
 
Example 13
Source File: CfSampleData.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public CfSampleData(final String sampleId)
{
    SampleId = sampleId;
    Chains = Maps.newHashMap();
    CfSvList = Lists.newArrayList();
    UnchainedSvList = Lists.newArrayList();
    ClusterChainOverlaps = Lists.newArrayList();
    SvProximityDistance = Maps.newHashMap();
}
 
Example 14
Source File: AbstractCachingService.java    From platform with Apache License 2.0 4 votes vote down vote up
/**
 * @see BaseService#findAllById(Iterable)
 */
@Override
public List<T> findAllById(Iterable<K> ids) {
    return Lists.newArrayList(this.repository.findAllById(ids).iterator());
}
 
Example 15
Source File: FusionWriter.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
public static Map<String,List<ReadRecord>> loadChimericReads(final String inputFile)
{
    Map<String,List<ReadRecord>> readsMap = Maps.newHashMap();

    if(!Files.exists(Paths.get(inputFile)))
    {
        ISF_LOGGER.error("invalid chimeric reads file: {}", inputFile);
        return readsMap;
    }

    try
    {
        BufferedReader fileReader = new BufferedReader(new FileReader(inputFile));

        // skip field names
        String line = fileReader.readLine();

        if (line == null)
        {
            ISF_LOGGER.error("empty chimeric reads file: {}", inputFile);
            return readsMap;
        }

        final Map<String,Integer> fieldsMap  = createFieldsIndexMap(line, DELIMITER);
        String currentReadId = "";
        List<ReadRecord> currentReads = null;

        int readId = fieldsMap.get("ReadId");
        int chr = fieldsMap.get("Chromosome");
        int posStart = fieldsMap.get("PosStart");
        int posEnd = fieldsMap.get("PosEnd");
        int cigar = fieldsMap.get("Cigar");
        int insertSize = fieldsMap.get("InsertSize");
        int flags = fieldsMap.get("Flags");
        int suppAlgn = fieldsMap.get("SuppAlign");
        int bases = fieldsMap.get("Bases");
        int mateChr = fieldsMap.get("MateChr");
        int matePosStart = fieldsMap.get("MatePosStart");
        int geneSet = fieldsMap.get("GeneSet");
        int bestMatch = fieldsMap.get("BestMatch");
        int transExonData = fieldsMap.get("TransExonData");

        while ((line = fileReader.readLine()) != null)
        {
            String[] items = line.split(DELIMITER, -1);

            ReadRecord read = new ReadRecord(
                    items[readId],
                    items[chr],
                    Integer.parseInt(items[posStart]),
                    Integer.parseInt(items[posEnd]),
                    items[bases],
                    cigarFromStr((items[cigar])),
                    Integer.parseInt(items[insertSize]),
                    Integer.parseInt(items[flags]),
                    items[mateChr],
                    Integer.parseInt(items[matePosStart]));

            String saData = items[suppAlgn];

            if(!saData.equals("NONE"))
                read.setSuppAlignment(saData);

            read.setGeneCollection(SE_START,Integer.parseInt(items[geneSet]), true);
            read.setGeneCollection(SE_END,Integer.parseInt(items[geneSet]), true);

            RegionMatchType matchType = RegionMatchType.valueOf(items[bestMatch]);

            if(matchType != NONE)
            {
                List<TransExonRef> transExonRefs = parseTransExonRefs(items[transExonData]);
                read.getTransExonRefs().put(matchType, transExonRefs);
            }

            if(!read.Id.equals(currentReadId))
            {
                currentReadId = read.Id;
                currentReads = Lists.newArrayList();
                readsMap.put(read.Id, currentReads);
            }

            currentReads.add(read);
        }

        ISF_LOGGER.info("loaded {} chimeric fragment reads from file({})", readsMap.size(), inputFile);
    }
    catch (IOException e)
    {
        ISF_LOGGER.warn("failed to load chimeric reads file({}): {}", inputFile, e.toString());
    }

    return readsMap;
}
 
Example 16
Source File: Flink111Shims.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public List collectToList(Object table) throws Exception {
  return Lists.newArrayList(((Table) table).execute().collect());
}
 
Example 17
Source File: TransvarConverter.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
private static List<String> extractCandidateAlternativeCodonsFromMessageField(@NotNull String messageField) {
    String fieldValue = extractOptionalValueFromMessageField(messageField, "candidate_alternative_sequence");

    return fieldValue != null ? Arrays.asList(fieldValue.split("/")) : Lists.newArrayList();
}
 
Example 18
Source File: ExposedPortsTest.java    From docker-java with Apache License 2.0 4 votes vote down vote up
private List<Entry<String, JsonNode>> getJsonEntries(String json) throws Exception {
    JsonNode jsonNode = JSONTestHelper.getMapper().readValue(json, JsonNode.class);
    return Lists.newArrayList(jsonNode.fields());
}
 
Example 19
Source File: DingMsgSender.java    From WePush with MIT License 4 votes vote down vote up
public SendResult sendRobotMsg(String[] msgData) {
    SendResult sendResult = new SendResult();

    try {
        DingTalkClient client = getRobotClient();
        OapiRobotSendRequest request2 = new OapiRobotSendRequest();
        DingMsg dingMsg = dingMsgMaker.makeMsg(msgData);
        if ("文本消息".equals(DingMsgMaker.msgType)) {
            request2.setMsgtype("text");
            OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
            text.setContent(dingMsg.getContent());
            request2.setText(text);
            OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
            if (msgData != null && StringUtils.isNotBlank(msgData[0])) {
                List<String> mobiles = Lists.newArrayList();
                mobiles.add(msgData[0]);
                at.setAtMobiles(mobiles);
            } else {
                at.setIsAtAll("true");
            }
            request2.setAt(at);
        } else if ("链接消息".equals(DingMsgMaker.msgType)) {
            request2.setMsgtype("link");
            OapiRobotSendRequest.Link link = new OapiRobotSendRequest.Link();
            link.setMessageUrl(dingMsg.getUrl());
            link.setPicUrl(dingMsg.getPicUrl());
            link.setTitle(dingMsg.getTitle());
            link.setText(dingMsg.getContent());
            request2.setLink(link);
        } else if ("markdown消息".equals(DingMsgMaker.msgType)) {
            request2.setMsgtype("markdown");
            OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
            markdown.setTitle(dingMsg.getTitle());
            markdown.setText(dingMsg.getContent());
            request2.setMarkdown(markdown);
        } else if ("卡片消息".equals(DingMsgMaker.msgType)) {
            request2.setMsgtype("actionCard");
            OapiRobotSendRequest.Actioncard actionCard = new OapiRobotSendRequest.Actioncard();
            actionCard.setTitle(dingMsg.getTitle());
            actionCard.setText(dingMsg.getContent());
            actionCard.setSingleTitle(dingMsg.getBtnTxt());
            actionCard.setSingleURL(dingMsg.getBtnUrl());
            request2.setActionCard(actionCard);
        }

        if (PushControl.dryRun) {
            sendResult.setSuccess(true);
            return sendResult;
        } else {
            OapiRobotSendResponse response2 = client.execute(request2);
            if (response2.getErrcode() != 0) {
                sendResult.setSuccess(false);
                sendResult.setInfo(response2.getErrmsg());
                log.error(response2.getErrmsg());
                return sendResult;
            }
        }
    } catch (Exception e) {
        sendResult.setSuccess(false);
        sendResult.setInfo(e.getMessage());
        log.error(e.toString());
        return sendResult;
    }

    sendResult.setSuccess(true);
    return sendResult;
}
 
Example 20
Source File: Rearrangement.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
public static List<VariantHotspot> moveLeft(boolean delete, int position, int indelLength, int readIndex, byte[] readBases,
        int refIndex, byte[] refBases) {
    int absIndelLength = Math.abs(indelLength);
    int minReadIndex = Math.max(0, readIndex - absIndelLength);
    int maxRefIndex = Math.max(0, refIndex - absIndelLength);

    int indelIndex = readIndex + absIndelLength - 1;

    int sameBases = 0;
    while (refIndex >= maxRefIndex && indelIndex >= minReadIndex && readBases[indelIndex] == refBases[refIndex]) {
        sameBases++;
        indelIndex--;
        refIndex--;
    }

    int snvLength = 0;
    while (refIndex >= maxRefIndex && indelIndex >= minReadIndex && readBases[indelIndex] != refBases[refIndex]) {
        snvLength++;
        indelIndex--;
        refIndex--;
    }

    int sameBases2 = 0;
    while (refIndex >= maxRefIndex && indelIndex >= minReadIndex && readBases[indelIndex] == refBases[refIndex]) {
        sameBases2++;
        indelIndex--;
        refIndex--;
    }

    if (sameBases == 0 || snvLength == 0 || sameBases2 == 0 || snvLength > MAX_MNV_LENGTH) {
        return Collections.emptyList();
    }

    int indelShift = sameBases + snvLength + sameBases2;

    final List<VariantHotspot> result = Lists.newArrayList();

    final String indelRef = new String(refBases, refIndex, 1);
    final String indelAlt = new String(readBases, readIndex - indelShift, absIndelLength);

    VariantHotspot indel = ImmutableVariantHotspotImpl.builder()
            .chromosome("1")
            .position(position - indelShift)
            .ref(delete ? indelAlt : indelRef)
            .alt(delete ? indelRef : indelAlt)
            .build();
    result.add(indel);

    final String snvRef = new String(refBases, refIndex + sameBases2 + 1, snvLength);
    final String snvAlt = new String(readBases, refIndex + sameBases2 + 1 + absIndelLength - 1, snvLength);

    VariantHotspot snv = ImmutableVariantHotspotImpl.builder()
            .chromosome("1")
            .position(position - indelShift + sameBases2 + 1 + (delete ? absIndelLength - 1 : 0))
            .ref(delete ? snvAlt : snvRef)
            .alt(delete ? snvRef : snvAlt)
            .build();
    result.add(snv);

    return result;
}