Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Pair<BufferedReader, InputStream> getInResourceByReader(String resourcePa
VfsParam param = new VfsParam();
InputStream stream;
try {
ConvertUtil.convertToTarget(param, colmeta.getResourceCfgMap());
ConvertUtil.convertToTarget(colmeta.getResourceCfgMap(), param);
FileObject fileObject = manager.resolveFile(getUriByParam(param, resourcePath).toString(), getOptions(param));
checkAndSetFileObject(fileObject);
stream = getInResource(fileObject, colmeta);
Expand Down Expand Up @@ -92,7 +92,7 @@ public OutputStream getOutResourceByStream(String resourcePath) throws IOExcepti
public InputStream getInResourceByStream(String resourcePath) throws IOException {
VfsParam param = new VfsParam();
try {
ConvertUtil.convertToTarget(param, colmeta.getResourceCfgMap());
ConvertUtil.convertToTarget(colmeta.getResourceCfgMap(), param);
FileObject fileObject = manager.resolveFile(getUriByParam(param, resourcePath).toString(), getOptions(param));
checkAndSetFileObject(fileObject);
return getInResource(fileObject, colmeta);
Expand All @@ -104,7 +104,7 @@ public InputStream getInResourceByStream(String resourcePath) throws IOException
public static FileObject getFileObject(FileSystemManager manager, DataCollectionMeta meta, String resPath) throws IOException {
VfsParam param = new VfsParam();
try {
ConvertUtil.convertToTarget(param, meta.getResourceCfgMap());
ConvertUtil.convertToTarget(meta.getResourceCfgMap(), param);
return manager.resolveFile(getUriByParam(param, resPath).toString(), getOptions(param));
} catch (Exception ex) {
throw new IOException(ex);
Expand Down Expand Up @@ -162,7 +162,7 @@ public List<String> listFilePath(VfsParam param, String path) {

public FileObject createNotExists(DataCollectionMeta meta, String resourcePath) throws Exception {
VfsParam param = new VfsParam();
ConvertUtil.convertToTarget(param, meta.getResourceCfgMap());
ConvertUtil.convertToTarget(meta.getResourceCfgMap(), param);
try (FileObject fo = manager.resolveFile(getUriByParam(param, resourcePath).toString(), getOptions(param))) {
if (fo.exists()) {
if (FileType.FOLDER.equals(fo.getType())) {
Expand Down Expand Up @@ -209,7 +209,7 @@ public OutputStream getRawOutputStream(String resourcePath) throws IOException {
public InputStream getRawInputStream(String resourcePath) throws IOException {
VfsParam param = new VfsParam();
try {
ConvertUtil.convertToTarget(param, colmeta.getResourceCfgMap());
ConvertUtil.convertToTarget(colmeta.getResourceCfgMap(), param);
FileObject fileObject = manager.resolveFile(getUriByParam(param, resourcePath).toString(), getOptions(param));
checkAndSetFileObject(fileObject);
return getRawInResource(fileObject, colmeta);
Expand Down Expand Up @@ -284,7 +284,7 @@ public VfsParam returnFtpParam(String hostName, int port, String userName, Strin
public boolean exists(String resourcePath) throws IOException {
VfsParam param = new VfsParam();
try {
ConvertUtil.convertToTarget(param, colmeta.getResourceCfgMap());
ConvertUtil.convertToTarget(colmeta.getResourceCfgMap(), param);
} catch (Exception ex) {
throw new IOException(ex);
}
Expand All @@ -299,7 +299,7 @@ public boolean exists(String resourcePath) throws IOException {
public long getInputStreamSize(String resourcePath) throws IOException {
VfsParam param = new VfsParam();
try {
ConvertUtil.convertToTarget(param, colmeta.getResourceCfgMap());
ConvertUtil.convertToTarget(colmeta.getResourceCfgMap(), param);
} catch (Exception ex) {
throw new IOException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.robin.core.fileaccess.fs;

import com.robin.core.base.exception.MissingConfigException;
import com.robin.core.base.util.Const;
import com.robin.core.fileaccess.meta.DataCollectionMeta;
import lombok.NonNull;
import org.springframework.util.ObjectUtils;
Expand All @@ -21,7 +22,27 @@ public static AbstractFileSystemAccessor getResourceAccessorByType(@NonNull Stri
try {
Class<? extends IFileSystemAccessor> clazz = accessorMap.get(resType);
if (!ObjectUtils.isEmpty(clazz)) {
accessor = (AbstractFileSystemAccessor) clazz.getConstructor().newInstance();
if(LocalFileSystemAccessor.class.isAssignableFrom(clazz)){
accessor=LocalFileSystemAccessor.getInstance();
}else {
accessor = (AbstractFileSystemAccessor) clazz.getConstructor().newInstance();
}
}
} catch (Exception ex) {
throw new MissingConfigException(ex);
}
return accessor;
}
public static AbstractFileSystemAccessor getResourceAccessorByType(@NonNull Const.FILESYSTEM fsType) throws MissingConfigException {
AbstractFileSystemAccessor accessor = null;
try {
Class<? extends IFileSystemAccessor> clazz = accessorMap.get(fsType.getValue());
if (!ObjectUtils.isEmpty(clazz)) {
if(LocalFileSystemAccessor.class.isAssignableFrom(clazz)){
accessor=LocalFileSystemAccessor.getInstance();
}else {
accessor = (AbstractFileSystemAccessor) clazz.getConstructor().newInstance();
}
}
} catch (Exception ex) {
throw new MissingConfigException(ex);
Expand All @@ -47,10 +68,30 @@ public static AbstractFileSystemAccessor getResourceAccessorByType(@NonNull Stri
}
return accessor;
}
public static AbstractFileSystemAccessor getResourceAccessorByType(@NonNull Const.FILESYSTEM resType, @NonNull DataCollectionMeta colmeta) throws MissingConfigException {
AbstractFileSystemAccessor accessor = null;
try {
Class<? extends IFileSystemAccessor> clazz = accessorMap.get(resType.getValue());
if (!ObjectUtils.isEmpty(clazz)) {
if(LocalFileSystemAccessor.class.isAssignableFrom(clazz)){
return LocalFileSystemAccessor.getInstance();
}else {
accessor = (AbstractFileSystemAccessor) clazz.getConstructor().newInstance();
if (!ObjectUtils.isEmpty(colmeta)) {
accessor.init(colmeta);
}
}
}
} catch (Exception ex) {
throw new MissingConfigException(ex);
}
return accessor;
}

private static void discoverAccessor(Map<String, Class<? extends IFileSystemAccessor>> accessorMap) {
ServiceLoader.load(IFileSystemAccessor.class).iterator().forEachRemaining(i -> {
accessorMap.put(i.getIdentifier(), i.getClass());
});
accessorMap.put(Const.FILESYSTEM.LOCAL.getValue(), LocalFileSystemAccessor.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.robin.core.fileaccess.util.PolandNotationUtil;
import com.robin.core.fileaccess.util.ResourceUtil;
import com.robin.core.fileaccess.util.SqlContentResolver;
import org.apache.avro.Schema;
import org.apache.calcite.config.Lex;
import org.apache.calcite.sql.*;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -73,6 +74,7 @@ public abstract class AbstractFileIterator implements IResourceIterator {

protected SqlSegment segment;
protected Iterator<Map.Entry<String,Map<String,Object>>> groupIter;
protected Schema avroSchema;

public AbstractFileIterator() {

Expand Down Expand Up @@ -328,4 +330,21 @@ private void appendByType(StringBuilder builder,Object value){
builder.append(value).append("|");
}
}

@Override
public void remove() {
hasNext();
}

public Schema getSchema() {
return avroSchema;
}

public Map<String, DataSetColumnMeta> getColumnMap() {
return columnMap;
}

public SqlSegment getSegment() {
return segment;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.robin.core.fileaccess.iterator;
import com.robin.core.fileaccess.fs.AbstractFileSystemAccessor;
import org.apache.avro.Schema;

import java.io.BufferedReader;
import java.io.Closeable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static IResourceIterator getProcessIteratorByType(DataCollectionMeta colm
public static IResourceIterator getProcessIteratorByPath(DataCollectionMeta colmeta,InputStream in) throws IOException{
FileUtils.FileContent content=FileUtils.parseFile(colmeta.getPath());
colmeta.setContent(content);
String fileFormat=content.getFileFormat();
String fileFormat=content.getFileFormat().getValue();
if(StringUtils.isEmpty(colmeta.getFileFormat())){
colmeta.setFileFormat(fileFormat);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ private static String getFileType(DataCollectionMeta colmeta) {
if(ObjectUtils.isEmpty(fileType)){
FileUtils.FileContent content=FileUtils.parseFile(colmeta.getPath());
colmeta.setContent(content);
fileType=content.getFileFormat();
fileType=content.getFileFormat().getValue();
}
return fileType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public abstract class AbstractFileWriter implements IResourceWriter {
protected AbstractFileSystemAccessor accessUtil;
protected String identifier;
protected boolean useBufferedWriter=false;
protected boolean useRawOutputStream=false;

public AbstractFileWriter(){

Expand Down Expand Up @@ -105,7 +106,11 @@ public void initalize() throws IOException{
public void beginWrite() throws IOException{
if(out==null){
checkAccessUtil(colmeta.getPath());
out = accessUtil.getOutResourceByStream(ResourceUtil.getProcessPath(colmeta.getPath()));
if(!useRawOutputStream) {
out = accessUtil.getOutResourceByStream(ResourceUtil.getProcessPath(colmeta.getPath()));
}else{
out = accessUtil.getRawOutputStream(ResourceUtil.getProcessPath(colmeta.getPath()));
}
if(useBufferedWriter) {
writer = new BufferedWriter(new OutputStreamWriter(out));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@
import java.io.IOException;
import java.util.*;

/**
* <p>Project: frame</p>
* <p>
* <p>Description:com.robin.core.fileaccess.writer</p>
* <p>
* <p>Copyright: Copyright (c) 2018 create at 2018年10月31日</p>
* <p>
* <p>Company: zhcx_DEV</p>
*
* @author robinjim
* @version 1.0
*/

public abstract class AbstractResourceWriter implements IResourceWriter{
protected DataCollectionMeta colmeta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static String getFileSuffix(DataCollectionMeta colmeta) {
if(ObjectUtils.isEmpty(fileSuffix)){
FileUtils.FileContent content=FileUtils.parseFile(colmeta.getPath());
colmeta.setContent(content);
fileSuffix=content.getFileFormat();
fileSuffix=content.getFileFormat().getValue();
}
return fileSuffix;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
com.robin.core.fileaccess.fs.ApacheVfsFileSystemAccessor
com.robin.core.fileaccess.fs.LocalFileSystemAccessor
com.robin.core.fileaccess.fs.ApacheVfsFileSystemAccessor
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.robin.core.base.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ServerlessFunction {
String value() default "";
String initFunc() default "";
String initParam() default "";
String method() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.robin.core.base.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ServerlessMethodParam {
String value() default "";
}
3 changes: 1 addition & 2 deletions core/src/main/java/com/robin/core/base/dao/SqlMapperDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import javax.sql.DataSource;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
Expand Down Expand Up @@ -120,7 +119,7 @@ private Map<String, Object> wrapSqlAndParameter(String nameSpace, String id, Str
}
} else {
try {
ConvertUtil.objectToMapObj(paramMap, params[0]);
ConvertUtil.objectToMapObj(params[0], paramMap);
} catch (Exception ex) {
throw new DAOException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String getUrl(){
return param.getUrlByMeta(this);
}
protected void processParam(Map<String,String> map) throws Exception{
ConvertUtil.objectToMap(map, param);
ConvertUtil.objectToMap(param, map);
}

protected BaseDataBaseMeta(DataBaseParam param){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public String getUrlByMeta(BaseDataBaseMeta dbMeta){
}
protected Map<String,String> processParam() throws Exception{
Map<String,String> map=new HashMap<>();
ConvertUtil.objectToMap(map, this);
ConvertUtil.objectToMap(this, map);
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ public boolean deleteByIds(List<P> ids) {
@Override
@Transactional(rollbackFor = RuntimeException.class)
public boolean deleteByField(SFunction<T,?> queryField,Const.OPERATOR operator,Object... value) {
QueryWrapper<T> queryWrapper = QueryWrapperUtils.getWrapper(queryField, operator, value);
try{
/*queryWrapper.eq(statusColumn,Const.VALID);
T vo=voType.getDeclaredConstructor().newInstance();
getStatusMethod.bindTo(vo).invoke(Const.INVALID);*/

return this.remove(queryWrapper);
}catch (Throwable ex){
throw new ServiceException(ex.getMessage());
}
}
@Override
@Transactional(rollbackFor = RuntimeException.class)
public boolean deleteLogicByField(SFunction<T,?> queryField,Const.OPERATOR operator,Object... value) {
QueryWrapper<T> queryWrapper = QueryWrapperUtils.getWrapper(queryField, operator, value);
try{
queryWrapper.eq(statusColumn,Const.VALID);
Expand All @@ -172,6 +186,7 @@ public boolean deleteByLogic(List<P> ids, SFunction<T,?> logicField){




@Override
public List<T> selectByField(String columName, Object value) {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
Expand Down Expand Up @@ -467,7 +482,7 @@ public boolean createWithRequest(Object requsetObj) {
try {
T obj = voType.newInstance();
if (requsetObj.getClass().getInterfaces().length > 0 && requsetObj.getClass().getInterfaces()[0].isAssignableFrom(Map.class)) {
ConvertUtil.mapToBaseObject(obj, (HashMap) requsetObj);
ConvertUtil.mapToBaseObject((HashMap) requsetObj, obj);
} else {
Map<String, MethodHandle> modelGetMetholds = ReflectUtils.returnGetMethodHandle(requsetObj.getClass());
Iterator<Map.Entry<String, MethodHandle>> iter = modelGetMetholds.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public interface IMybatisBaseService<T extends BaseObject,P extends Serializable
List<P> parseId(String ids) throws ServiceException;
boolean deleteByIds(List<P> ids);
boolean deleteByField(SFunction<T,?> queryField,Const.OPERATOR oper,Object... value);
boolean deleteLogicByField(SFunction<T,?> queryField,Const.OPERATOR oper,Object... value);
boolean updateModelById(T entity);
void queryBySelectId(PageQuery<Map<String,Object>> query) throws ServiceException;
List<Map<String, Object>> queryBySql(String sqlstr, Object... objects) throws ServiceException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@
import com.robin.core.convert.util.ConvertUtil;
import com.robin.core.query.util.Condition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -185,7 +182,7 @@ protected static Object returnTimeColumn(String value, Class<?> clazz) {
}
private static Map<String, Object> returnValueMap(PageDTO targetObj) throws Exception {
Map<String, Object> getMap = new HashMap<>();
ConvertUtil.objectToMapObj(getMap,targetObj,"param","order","page","limit","size","orderField","orderBy");
ConvertUtil.objectToMapObj(targetObj, getMap, "param","order","page","limit","size","orderField","orderBy");
if (!CollectionUtils.isEmpty(targetObj.getParam())) {
getMap.putAll(targetObj.getParam());
}
Expand Down
Loading