Skip to content

Commit 460febf

Browse files
committed
sonar fix
1 parent af8b455 commit 460febf

File tree

11 files changed

+27
-45
lines changed

11 files changed

+27
-45
lines changed

common/src/main/java/com/robin/comm/dal/holder/RecordWriterHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void init(DataCollectionMeta colmeta) throws Exception {
3232
if(!colmeta.isFsTag()) {
3333
writer = TextFileWriterFactory.getWriterByPath(colmeta, outStream);
3434
} else{
35-
writer= CommResWriterFactory.getFileWriterByType(colmeta.getResType(),colmeta);
35+
writer= CommResWriterFactory.getFileWriterByType(colmeta.getFileFormat(),colmeta);
3636
}
3737
}
3838
public void writeRecord(Map<String,Object> map) throws IOException, OperationNotSupportedException {

common/src/main/java/com/robin/core/fileaccess/iterator/ArffFileIterator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public ArffFileIterator(DataCollectionMeta colmeta) {
2525
@Override
2626
public void beforeProcess() {
2727
super.beforeProcess();
28-
if(CollectionUtils.isEmpty(colmeta.getColumnList())){
29-
if(!ObjectUtils.isEmpty(reader)){
28+
if(CollectionUtils.isEmpty(colmeta.getColumnList()) && (!ObjectUtils.isEmpty(reader))){
3029
try {
3130
while (!(readLineStr = reader.readLine()).equalsIgnoreCase("@data")) {
3231
if(StringUtils.startsWithIgnoreCase(readLineStr,"@RELATION ")){
@@ -39,7 +38,7 @@ public void beforeProcess() {
3938
}catch (IOException ex){
4039
logger.info("{}",ex.getMessage());
4140
}
42-
}
41+
4342
}
4443
}
4544
private DataSetColumnMeta parseDefine(String content){

common/src/main/java/com/robin/core/resaccess/CommResIteratorFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212

1313
@Slf4j
1414
public class CommResIteratorFactory {
15+
private CommResIteratorFactory(){
16+
17+
}
1518
private static Map<String,Class<? extends IResourceIterator>> iterMap =new HashMap<>();
1619
static {
1720
discoverIterator(iterMap);
1821
}
1922

20-
public static AbstractResIterator getIterator(Long resType, DataCollectionMeta colmeta) {
23+
public static AbstractResIterator getIterator(String resType, DataCollectionMeta colmeta) {
2124
AbstractResIterator iterator = null;
2225
Class<? extends IResourceIterator> clazz = iterMap.get(resType);
2326
try {

common/src/main/java/com/robin/core/resaccess/CommResWriterFactory.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616

1717
@Slf4j
1818
public class CommResWriterFactory {
19-
private static final String KAFKA_WRITER_CLASS = "com.robin.comm.resaccess.writer.KafkaResourceWriter";
20-
private static final String CASSANDRA_WRITER_CLASS = "com.robin.comm.resaccess.writer.CassandraResourceWriter";
21-
private static final String MONGO_WRITER_CLASS = "com.robin.comm.resaccess.writer.MongoResourceWriter";
22-
private static final String REDIS_WRITER_CLASS = "com.robin.comm.resaccess.writer.RedisResourceWriter";
23-
private static final String ROCKET_WRITER_CLASS = "com.robin.comm.resaccess.writer.RocketResourceWriter";
24-
private static final String HBASE_WRITER_CLASS = "com.robin.comm.resaccess.writer.HbaseResourceWriter";
2519

2620
private static Map<String,Class<? extends IResourceWriter>> writerMap =new HashMap<>();
2721
static {
@@ -30,7 +24,7 @@ public class CommResWriterFactory {
3024
private CommResWriterFactory(){
3125

3226
}
33-
public static AbstractResourceWriter getFileWriterByType(Long resType, DataCollectionMeta colmeta) {
27+
public static AbstractResourceWriter getFileWriterByType(String resType, DataCollectionMeta colmeta) {
3428
AbstractResourceWriter fileWriter = null;
3529
Class<? extends IResourceWriter> clazz = writerMap.get(resType);
3630
try {

core/src/main/java/com/robin/core/base/dao/CommJdbcUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private Object getRecordValue(ResultSetMetaData rsmd, ResultSet rs, LobHandler l
318318
return retObj;
319319
}
320320

321-
static void setTargetValue(Object target, Object value, String columnName, String columnType, LobHandler handler, PageQuery<Map<String, Object>> pageQuery) throws DAOException {
321+
static void setTargetValue(Object target, Object value, String columnName, String columnType, PageQuery<Map<String, Object>> pageQuery) throws DAOException {
322322
try {
323323
if (value != null) {
324324
Object targetValue = null;

core/src/main/java/com/robin/core/base/dao/SqlMapperDao.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private static ResultSetExtractor<List<?>> resultSetExtractor(SqlMapperConfigure
194194
Map<String, Object> map = new HashMap<>();
195195
for (int i = 0; i < count; i++) {
196196
String columnName = rsmd.getColumnName(i + 1);
197-
CommJdbcUtil.setTargetValue(map, resultSet.getObject(i + 1), segment1.getColumnMapper().get(columnName).left, segment1.getColumnMapper().get(columnName).right, lobHandler, pageQuery);
197+
CommJdbcUtil.setTargetValue(map, resultSet.getObject(i + 1), segment1.getColumnMapper().get(columnName).left, segment1.getColumnMapper().get(columnName).right, pageQuery);
198198
}
199199
retList.add(map);
200200
} else {
@@ -208,7 +208,7 @@ private static ResultSetExtractor<List<?>> resultSetExtractor(SqlMapperConfigure
208208
if (!segment1.getColumnMapper().containsKey(columnName)) {
209209
throw new DAOException("property " + columnName + " not exist in class " + segment1.getClassName());
210210
}
211-
CommJdbcUtil.setTargetValue(targetObject, resultSet.getObject(i + 1), segment1.getColumnMapper().get(columnName).left, segment1.getColumnMapper().get(columnName).right, lobHandler, pageQuery);
211+
CommJdbcUtil.setTargetValue(targetObject, resultSet.getObject(i + 1), segment1.getColumnMapper().get(columnName).left, segment1.getColumnMapper().get(columnName).right, pageQuery);
212212
}
213213
retList.add(targetObject);
214214
} catch (IllegalAccessException|InstantiationException ex1) {
@@ -220,7 +220,7 @@ private static ResultSetExtractor<List<?>> resultSetExtractor(SqlMapperConfigure
220220
Map<String, Object> map = new HashMap<>();
221221
for (int i = 0; i < count; i++) {
222222
String columnName = rsmd.getColumnName(i + 1);
223-
CommJdbcUtil.setTargetValue(map, resultSet.getObject(i + 1), columnName, null, lobHandler, pageQuery);
223+
CommJdbcUtil.setTargetValue(map, resultSet.getObject(i + 1), columnName, null, pageQuery);
224224
}
225225
retList.add(map);
226226
}

core/src/main/java/com/robin/core/base/datameta/DataBaseUtil.java

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@
4242
import java.util.stream.Collectors;
4343

4444
@Slf4j
45+
@SuppressWarnings("unused")
4546
public class DataBaseUtil {
4647
private Connection connection;
4748
private static final Logger logger = LoggerFactory.getLogger(DataBaseUtil.class);
4849
private BaseDataBaseMeta dataBaseMeta;
49-
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
50-
private static final SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddhhmmss");
51-
private static final SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
52-
private static final SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd");
50+
private static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
51+
private static final DateTimeFormatter format1 = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
52+
private static final DateTimeFormatter format2 = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss.SSS");
53+
private static final DateTimeFormatter format3 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
5354

5455
public void connect(BaseDataBaseMeta meta) throws ClassNotFoundException, SQLException {
5556
dataBaseMeta = meta;
@@ -148,11 +149,7 @@ public List<DataBaseColumnMeta> getTableMetaByTableName(String tablename, String
148149
if(!org.springframework.util.StringUtils.isEmpty(defaultValue)) {
149150
datameta.setDefaultValue(defaultValue);
150151
}
151-
if (pklist.contains(columnname)) {
152-
datameta.setPrimaryKey(true);
153-
} else {
154-
datameta.setPrimaryKey(false);
155-
}
152+
datameta.setPrimaryKey(pklist.contains(columnname));
156153
columnlist.add(datameta);
157154
}
158155
return columnlist;
@@ -235,11 +232,7 @@ public static List<DataBaseColumnMeta> getTableMetaByTableName(Connection conn,
235232
}
236233
}
237234
setType(columnname, columnType, rs.getInt("DATA_TYPE"), rs.getString("TYPE_NAME"), datalength, nullable, comment, precise, scale, datameta);
238-
if (pklist != null && pklist.contains(columnname)) {
239-
datameta.setPrimaryKey(true);
240-
} else {
241-
datameta.setPrimaryKey(false);
242-
}
235+
datameta.setPrimaryKey(pklist != null && pklist.contains(columnname));
243236
columnlist.add(datameta);
244237
}
245238
return columnlist;
@@ -311,8 +304,7 @@ public static List<DataBaseColumnMeta> getQueryMeta(Connection conn, String sql)
311304
}
312305
}
313306

314-
public static String translateDbType(Integer dbType) {
315-
int type = dbType.intValue();
307+
public static String translateDbType(Integer type) {
316308
String retStr;
317309
if (type == Types.INTEGER || type == Types.TINYINT) {
318310
retStr = Const.META_TYPE_INTEGER;
@@ -344,7 +336,7 @@ public static Map<String, Object> transformDbTypeByObj(Object obj) {
344336
Map<String, Object> retMap = new HashMap<>();
345337
String type = null;
346338

347-
SimpleDateFormat targetFormat = null;
339+
DateTimeFormatter targetFormat = null;
348340
if (obj instanceof Long) {
349341
type = Const.META_TYPE_BIGINT;
350342
} else if (obj instanceof Integer) {
@@ -374,7 +366,7 @@ public static Map<String, Object> transformDbTypeByObj(Object obj) {
374366
return retMap;
375367
}
376368

377-
private static boolean isStringValueDate(String value, SimpleDateFormat format) {
369+
private static boolean isStringValueDate(String value, DateTimeFormatter format) {
378370
try {
379371
format.parse(value);
380372
return true;
@@ -426,9 +418,8 @@ public static boolean isValueValid(Object value, String type) {
426418
validtag = true;
427419
}
428420
break;
429-
case Const.META_TYPE_STRING:
421+
default:
430422
validtag = true;
431-
break;
432423
}
433424
}
434425
return validtag;
@@ -473,7 +464,7 @@ public String generateCreateTableSql(BaseDataBaseMeta meta, List<DataBaseColumnM
473464
if (primaryKeys.contains(f.getColumnName())) {
474465
f.setNullable(false);
475466
}
476-
builder.append("\t").append(sqlGen.returnTypeDef(f.getColumnType().toString(), f)).append(",\n");
467+
builder.append("\t").append(sqlGen.returnTypeDef(f.getColumnType(), f)).append(",\n");
477468
});
478469
StringBuilder builder1 = new StringBuilder();
479470
primaryKeys.forEach(f -> {

core/src/main/java/com/robin/core/base/service/AbstractMybatisService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public T selectOne(Wrapper<T> wrapper) {
416416
public boolean deleteWithRequest(Object queryObject) {
417417
try {
418418
QueryWrapper<T> wrapper = wrapWithEntity(queryObject);
419-
return delete(wrapper);
419+
return SqlHelper.retBool(baseDao.delete(wrapper));
420420
} catch (Exception ex) {
421421
throw new ServiceException(ex);
422422
}
@@ -426,7 +426,7 @@ public boolean deleteWithRequest(Object queryObject) {
426426
public boolean updateWithRequest(T model, Object queryObject) {
427427
try {
428428
QueryWrapper<T> wrapper = wrapWithEntity(queryObject);
429-
return update(model, wrapper);
429+
return SqlHelper.retBool(baseDao.update(model, wrapper));
430430
} catch (Exception ex) {
431431
throw new ServiceException(ex);
432432
}

core/src/main/java/com/robin/core/base/util/Const.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public String getValue(){
442442
//定时任务触发时间点
443443
public static final String TRIGGER_TIMESPAN = "triggerTimeSpan";
444444

445-
public final static List<String> ESCAPE_CHARACTERS = new ArrayList<String>(
445+
public final static List<String> ESCAPE_CHARACTERS = new ArrayList<>(
446446
Lists.newArrayList("$", "(", ")", "*", "+", ".", "[",
447447
"?", "\\", "^", "{", "|"));
448448

core/src/main/java/com/robin/core/collection/util/CollectionMapConvert.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,12 @@ public static <T> List<T> filterListByColumnCondition(List<T> listobj, String sc
190190

191191
public static <T> String getColumnValueAppendBySeparate(List<T> listobj, Function<T,?> column, String separate) throws MissingConfigException,InvocationTargetException,IllegalAccessException {
192192
checkType(listobj);
193-
StringBuilder buffer = new StringBuilder();
194193
Assert.notNull(column,"");
195194
List<?> values= listobj.stream().collect(Collectors.mapping(column,Collectors.toList()));
196195
return StringUtils.join(values,separate);
197196
}
198197

199198
public static <T,P> List<P> getValueListBySeparate(List<T> listobj, Function<T,P> column) throws MissingConfigException,InvocationTargetException,IllegalAccessException {
200-
List<String> retList = new ArrayList<>();
201199
checkType(listobj);
202200
return listobj.stream().collect(Collectors.mapping(column,Collectors.toList()));
203201
}

0 commit comments

Comments
 (0)