Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* The MIT License (MIT)
*
* Copyright (c) 2011-2016 Incapture Technologies LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/package rapture.series.mem;
import rapture.common.SeriesValue;
import rapture.common.exception.RaptureException;
import rapture.common.exception.RaptureExceptionFactory;
import rapture.common.exception.RaptureExceptionFormatter;
import rapture.parser.CSVExtractor;
import rapture.util.ResourceLoader;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import org.antlr.runtime.RecognitionException;
import org.apache.log4j.Logger;
import com.google.common.base.Preconditions;
publicclassCSVSeriesStoreextendsMemorySeriesStore{
privatestaticfinal Logger log = Logger.getLogger(CSVSeriesStore.class);
boolean live = false;
@OverridepublicvoidaddDoubleToSeries(String key, String column, double value){
if (live) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
elsesuper.addDoubleToSeries(key, column, value);
}
@OverridepublicvoidaddLongToSeries(String key, String column, long value){
if (live) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
elsesuper.addDoubleToSeries(key, column, value);
}
@OverridepublicvoidaddStringToSeries(String key, String column, String value){
if (live) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
elsesuper.addStringToSeries(key, column, value);
}
@OverridepublicvoidaddStructureToSeries(String key, String column, String json){
if (live) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
elsesuper.addStructureToSeries(key, column, json);
}
@OverridepublicvoidaddPointToSeries(String key, SeriesValue value){
if (live) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
elsesuper.addPointToSeries(key, value);
}
@OverridepublicvoidaddDoublesToSeries(String key, List columns, List values){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoidaddLongsToSeries(String key, List columns, List values){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoidaddStringsToSeries(String key, List columns, List values){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoidaddStructuresToSeries(String key, List columns, List values){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoidaddPointsToSeries(String key, List value){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@Overridepublic Boolean deletePointsFromSeriesByPointKey(String key, List pointKeys){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoiddeletePointsFromSeries(String key){
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Read Only Repo");
}
@OverridepublicvoidsetConfig(Map config){
boolean useType = "true".equals(config.get("typerow"));
String filePath = config.get("filename");
Preconditions.checkArgument(filePath != null, "Mandatory argument filename missing");
String prefix = config.get("prefix");
if (prefix == null) prefix = "";
String content = ResourceLoader.getResourceAsString(null, filePath);
CSVSeriesCallback callback = new CSVSeriesCallback(this, useType, prefix);
try {
CSVExtractor.getCSV(content, callback);
} catch (RecognitionException e) {
RaptureException raptException = RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Error parsing csv config");
String message = RaptureExceptionFormatter.getExceptionMessage(raptException, e);
log.error(String.format("Error parsing csv content %s: %s", content, message));
throw raptException;
}
live = true;
}
}