forked from fanruan/finekit
Compare commits
38 Commits
Author | SHA1 | Date |
---|---|---|
richie | 298d68108e | 3 years ago |
左良 | 8304ca3fca | 3 years ago |
fanglei | d478c5195c | 4 years ago |
方磊 | 6c6d508a4d | 4 years ago |
fanglei | e2e8e2ae9b | 4 years ago |
方磊 | d7b8d62996 | 4 years ago |
fanglei | dfd16cb126 | 4 years ago |
方磊 | 198f73b578 | 4 years ago |
方磊 | 7013e6461f | 4 years ago |
方磊 | 649edf31f9 | 4 years ago |
fanglei | 2f51c2b3c0 | 4 years ago |
方磊 | b6778538bc | 4 years ago |
richie | 6df075061c | 4 years ago |
richie | 30b5970252 | 4 years ago |
Yvan | 521dd29c3e | 4 years ago |
richie | 8280abdf3b | 4 years ago |
lucian | c8fb5454f3 | 4 years ago |
richie | 22c28b7090 | 4 years ago |
Yvan | a1900cf1ba | 4 years ago |
richie | eaf185c3ed | 4 years ago |
Dylan.Liu | 753eb6961b | 4 years ago |
richie | c0cfb5d757 | 4 years ago |
Dylan.Liu | c7b4de0094 | 4 years ago |
Dylan.Liu | a74076a85f | 4 years ago |
richie | 49a526fe18 | 4 years ago |
Dylan.Liu | a5f9492492 | 4 years ago |
Dylan.Liu | 40754f05de | 4 years ago |
zed | 4793f9c62f | 4 years ago |
zed | afef877673 | 4 years ago |
zed | ed3d398e94 | 4 years ago |
zed | a7632f3931 | 4 years ago |
richie | f989336efe | 4 years ago |
zed | defd3cce2a | 4 years ago |
zed | 420bc83904 | 4 years ago |
zed | 8439799f7e | 4 years ago |
zed | fb3039634b | 4 years ago |
zed | 94a302baa3 | 4 years ago |
zed | 9cff6a3549 | 4 years ago |
39 changed files with 1077 additions and 46 deletions
@ -0,0 +1,17 @@
|
||||
package com.fanruan.api.cluster.resource; |
||||
|
||||
import com.fr.io.config.CommonRepoConfig; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/3 |
||||
*/ |
||||
public class BaseCommonRepoConfig extends CommonRepoConfig { |
||||
|
||||
private static final long serialVersionUID = 6713243696930557143L; |
||||
|
||||
public BaseCommonRepoConfig(String identity) { |
||||
super(identity); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fanruan.api.cluster.resource; |
||||
|
||||
import com.fr.decision.fileserver.FineFileServer; |
||||
import com.fr.io.config.RepositoryConfig; |
||||
|
||||
/** |
||||
* 文件服务器Kit. |
||||
* |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/12 |
||||
*/ |
||||
public class FineFileServerKit { |
||||
|
||||
/** |
||||
* 获取文件服务器当前配置. |
||||
* |
||||
* @return 文件服务器当前配置 |
||||
* @throws Exception 获取配置失败时异常 |
||||
*/ |
||||
public static <T extends RepositoryConfig> T getRepoConfig() throws Exception { |
||||
return FineFileServer.getInstance().getRepoConfig(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fanruan.api.cluster.resource; |
||||
|
||||
import com.fr.io.config.RepositoryConfig; |
||||
import com.fr.io.context.ResourceModuleContext; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/3 |
||||
*/ |
||||
public class ResourceModuleContextKit { |
||||
|
||||
public static <T extends RepositoryConfig> T getRepoConfig(String hdfs, String srcRepo) { |
||||
return ResourceModuleContext.getRepoConfig(hdfs, srcRepo); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fanruan.api.cluster.resource; |
||||
|
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.resource.WorkResource; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/3 |
||||
*/ |
||||
public class WorkContextKit { |
||||
public static WorkResource getWorkResource() { |
||||
return WorkContext.getWorkResource(); |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fanruan.api.cluster.state; |
||||
|
||||
import com.fr.store.impl.accessor.api.impl.StandAloneStore; |
||||
import com.fr.third.redis.clients.jedis.Jedis; |
||||
|
||||
/** |
||||
* 单机<code>Redis API</code>层. |
||||
* |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/18 |
||||
*/ |
||||
public class BaseStandAloneStore extends StandAloneStore { |
||||
public BaseStandAloneStore(Jedis jedis) { |
||||
super(jedis); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fanruan.api.cluster.state; |
||||
|
||||
import com.fr.collections.FineCollections; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/18 |
||||
*/ |
||||
public class FineCollectionsKit { |
||||
|
||||
public FineCollectionsKit() {} |
||||
|
||||
/** |
||||
* 销毁集群集合 |
||||
*/ |
||||
public static void destroy() { |
||||
FineCollections.getInstance().getClient().destroy(); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fanruan.api.cluster.state; |
||||
|
||||
import com.fr.store.impl.StoreTemplate; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/3 |
||||
*/ |
||||
public class StoreTemplateKit { |
||||
|
||||
public static void close() { |
||||
StoreTemplate.getInstance().close(); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fanruan.api.conf; |
||||
|
||||
import com.fr.config.MarketConfig; |
||||
|
||||
public class MarketConfigKit { |
||||
/** |
||||
* 获取服务器appId |
||||
* |
||||
* @return appId |
||||
*/ |
||||
public static String getAppId() { |
||||
return MarketConfig.getInstance().getCloudOperationMaintenanceId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取已登录帆软市场的用户名 |
||||
* |
||||
* @return userId |
||||
*/ |
||||
public static long getUserId() { |
||||
return MarketConfig.getInstance().getBbsUid(); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fanruan.api.design.ui.component; |
||||
|
||||
import com.fr.design.editlock.EditLockChangeEvent; |
||||
import com.fr.design.editlock.EditLockChangeListener; |
||||
import com.fr.design.editlock.EditLockUtils; |
||||
import com.fr.report.LockItem; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public class UILockButton extends UIButton implements EditLockChangeListener { |
||||
|
||||
/** |
||||
* 锁定状态图标 |
||||
*/ |
||||
private final Icon lockedIcon; |
||||
/** |
||||
* 正常状态图标 |
||||
*/ |
||||
private final Icon normalIcon; |
||||
/** |
||||
* 锁定状态的提示信息 |
||||
*/ |
||||
private final String lockedTooltips; |
||||
/** |
||||
* 正常状态的提示信息 |
||||
*/ |
||||
private final String normalTooltips; |
||||
|
||||
public UILockButton(Icon lockedIcon, Icon normalIcon, String lockedTooltips, String normalTooltips) { |
||||
super(); |
||||
this.lockedIcon = lockedIcon; |
||||
this.normalIcon = normalIcon; |
||||
this.lockedTooltips = lockedTooltips; |
||||
this.normalTooltips = normalTooltips; |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
boolean locked = EditLockUtils.isLocked(LockItem.CONNECTION); |
||||
this.setIcon(locked ? lockedIcon : normalIcon); |
||||
this.setToolTipText(locked ? lockedTooltips : normalTooltips); |
||||
} |
||||
|
||||
@Override |
||||
public void updateLockedState(EditLockChangeEvent event) { |
||||
this.setIcon(event.isLocked() ? lockedIcon : normalIcon); |
||||
this.setToolTipText(event.isLocked() ? lockedTooltips : normalTooltips); |
||||
this.repaint(); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fanruan.api.design.work.compat; |
||||
|
||||
import com.fanruan.api.design.ui.component.UIButton; |
||||
import com.fanruan.api.design.ui.component.UILockButton; |
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.editlock.ConnectionLockChangeChecker; |
||||
import com.fr.design.editlock.EditLockUtils; |
||||
import com.fr.report.LockItem; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2021/3/18 |
||||
* 用于兼容没有数据连接lock的版本 |
||||
*/ |
||||
public class ConnectionLockHelper { |
||||
|
||||
public static UIButton generateLockButton(Dimension buttonSize, ActionListener listener) { |
||||
UILockButton editButton = new UILockButton( |
||||
EditLockUtils.CONNECTION_LOCKED_ICON, |
||||
IconUtils.readIcon("/com/fr/design/images/m_web/connection"), |
||||
EditLockUtils.CONNECTION_LOCKED_TOOLTIPS, |
||||
null |
||||
); |
||||
editButton.setPreferredSize(buttonSize); |
||||
editButton.addActionListener(listener); |
||||
ConnectionLockChangeChecker.getInstance().addEditLockChangeListener(editButton); |
||||
return editButton; |
||||
} |
||||
|
||||
public static boolean doLock(Component component) { |
||||
// 尝试为数据连接加锁
|
||||
boolean actionLock = EditLockUtils.lock(LockItem.CONNECTION); |
||||
if (!actionLock) { |
||||
// 锁定失败,代表已经被其他用户锁定,跳出弹窗提示
|
||||
EditLockUtils.showLockMessage(component); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public static void unlock() { |
||||
// 关闭定义数据连接页面,为其解锁
|
||||
EditLockUtils.unlock(LockItem.CONNECTION); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,122 @@
|
||||
package com.fanruan.api.design.work.component; |
||||
|
||||
import com.fanruan.api.design.ui.component.UIButton; |
||||
import com.fanruan.api.design.ui.component.UIComboBox; |
||||
import com.fanruan.api.util.IOKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2021/3/18 |
||||
*/ |
||||
public abstract class ItemEditableComboBoxPanel extends JPanel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
protected static final Object EMPTY = new Object() { |
||||
public String toString() { |
||||
return StringKit.EMPTY; |
||||
} |
||||
}; |
||||
|
||||
protected UIComboBox<?> itemComboBox; |
||||
protected UIButton editButton; |
||||
protected UIButton refreshButton; |
||||
|
||||
public ItemEditableComboBoxPanel() { |
||||
super(); |
||||
|
||||
initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
this.setLayout(new BorderLayout(4, 4)); |
||||
Dimension buttonSize = new Dimension(26, 20); |
||||
itemComboBox = new UIComboBox<>(); |
||||
itemComboBox.setEnabled(true); |
||||
this.add(itemComboBox, BorderLayout.CENTER); |
||||
refreshButton = new UIButton(IOKit.readIcon("/com/fr/design/images/control/refresh.png")); |
||||
JPanel jPanel = new JPanel(new GridLayout(0, 2, 4, 4)); |
||||
editButton = initEditButton(editButton, buttonSize); |
||||
jPanel.add(editButton); |
||||
jPanel.add(refreshButton); |
||||
this.add(jPanel, BorderLayout.EAST); |
||||
refreshButton.setPreferredSize(buttonSize); |
||||
refreshButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
refreshItems(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
protected UIButton initEditButton(UIButton editButton, Dimension buttonSize) { |
||||
editButton = new UIButton(IOKit.readIcon("/com/fr/design/images/control/control-center2.png")); |
||||
editButton.setPreferredSize(buttonSize); |
||||
editButton.addActionListener(evt -> editItems()); |
||||
return editButton; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 给itemComboBox添加ActionListener |
||||
*/ |
||||
public void addComboBoxActionListener(ActionListener l) { |
||||
itemComboBox.addActionListener(l); |
||||
} |
||||
|
||||
protected void refreshItems() { |
||||
// 记录原来选中的Item,重新加载后需要再次选中
|
||||
Object lastSelectedItem = itemComboBox.getSelectedItem(); |
||||
|
||||
DefaultComboBoxModel<Object> model = ((DefaultComboBoxModel<Object>) itemComboBox.getModel()); |
||||
model.removeAllElements(); |
||||
|
||||
// 先加EMPTY,再加items
|
||||
model.addElement(EMPTY); |
||||
|
||||
java.util.Iterator<String> itemIt = items(); |
||||
while (itemIt.hasNext()) { |
||||
model.addElement(itemIt.next()); |
||||
} |
||||
|
||||
// 再次选中之前选中的Item
|
||||
int idx = model.getIndexOf(lastSelectedItem); |
||||
if (idx < 0) { |
||||
idx = 0; |
||||
} |
||||
itemComboBox.setSelectedIndex(idx); |
||||
} |
||||
|
||||
/* |
||||
* 得到其中的itemComboBox所选中的Item |
||||
*/ |
||||
public String getSelectedItem() { |
||||
Object selected = itemComboBox.getSelectedItem(); |
||||
|
||||
return selected instanceof String ? (String) selected : null; |
||||
} |
||||
|
||||
/* |
||||
* 选中name项 |
||||
*/ |
||||
public void setSelectedItem(String name) { |
||||
DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); |
||||
model.setSelectedItem(name); |
||||
} |
||||
|
||||
/* |
||||
* 刷新ComboBox.items |
||||
*/ |
||||
protected abstract java.util.Iterator<String> items(); |
||||
|
||||
/* |
||||
* 弹出对话框编辑Items |
||||
*/ |
||||
protected abstract void editItems(); |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fanruan.api.report; |
||||
|
||||
import com.fr.decision.webservice.v10.entry.ReportEntryService; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/12/14 |
||||
* 在平台挂查看FR模板的工具类 |
||||
*/ |
||||
public class ReportEntryKit { |
||||
|
||||
/** |
||||
* 获取FR模板树 |
||||
* |
||||
* @param currentUserId 当前用户id |
||||
* @param keyword keyword |
||||
* @return 模板树 |
||||
* @throws Exception 异常 |
||||
*/ |
||||
public static Object getReportTemplateTree(String currentUserId, String keyword) throws Exception { |
||||
return ReportEntryService.getInstance().getReportTemplateTree(currentUserId, keyword); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fanruan.api.cluster.state; |
||||
|
||||
import com.fr.collections.api.FineCollectionClient; |
||||
import com.fr.collections.api.FineCollectionClientWrapper; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/19 |
||||
*/ |
||||
public class FineCollectionsKitTest { |
||||
|
||||
@Test |
||||
public void testGetClient() throws Exception { |
||||
// test
|
||||
FineCollectionsKit.destroy(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fanruan.api.cluster.state; |
||||
|
||||
import com.fr.store.impl.accessor.FineStorePool; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
import static org.easymock.EasyMock.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author Dylan.Liu |
||||
* @version 10.0 |
||||
* Created by Dylan.Liu on 2021/1/19 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({FineStorePool.class}) |
||||
public class StoreTemplateKitTest { |
||||
|
||||
@Test |
||||
public void testClose() throws Exception { |
||||
// test
|
||||
FineStorePool fineStorePool = mock(FineStorePool.class); |
||||
fineStorePool.close(); |
||||
expectLastCall().times(1); |
||||
|
||||
PowerMock.mockStaticPartial(FineStorePool.class, "getPool"); |
||||
expect(FineStorePool.getPool()).andReturn(fineStorePool).times(1); |
||||
|
||||
PowerMock.replayAll(); |
||||
|
||||
StoreTemplateKit.close(); |
||||
|
||||
PowerMock.verifyAll(); |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fanruan.api.conf; |
||||
|
||||
import com.fr.config.Configuration; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.lang.reflect.Method; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/12/15 |
||||
*/ |
||||
public class ConfigurationKitTest { |
||||
|
||||
@Test |
||||
public void update() throws Exception { |
||||
|
||||
Class<?> classBook = Class.forName("com.fanruan.api.conf.ConfigurationKit"); |
||||
Assert.assertNotNull(classBook); |
||||
|
||||
Method method1 = classBook.getDeclaredMethod("getConfig", Configuration.class); |
||||
Assert.assertNotNull(method1); |
||||
|
||||
Method method2 = classBook.getDeclaredMethod("setConfig", Configuration.class, Map.class); |
||||
Assert.assertNotNull(method2); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fanruan.api.report; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/12/15 |
||||
*/ |
||||
public class ReportEntryKitTest { |
||||
|
||||
@Test |
||||
public void getReportTemplateTree() throws Exception { |
||||
|
||||
Class<?> classBook = Class.forName("com.fanruan.api.report.ReportEntryKit"); |
||||
Assert.assertNotNull(classBook); |
||||
|
||||
Method method1 = classBook.getDeclaredMethod("getReportTemplateTree", String.class, String.class); |
||||
Assert.assertNotNull(method1); |
||||
} |
||||
} |
@ -1,18 +1,25 @@
|
||||
package com.fanruan.api.security; |
||||
|
||||
import java.util.*; |
||||
|
||||
import com.fr.stable.CommonCodeUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class SecurityKitTest { |
||||
|
||||
@Test |
||||
public void passwordDecode(){ |
||||
public void passwordDecode() { |
||||
Assert.assertEquals(SecurityKit.passwordDecode("1234"), CommonCodeUtils.passwordDecode("1234")); |
||||
} |
||||
|
||||
@Test |
||||
public void passwordEncode(){ |
||||
public void passwordEncode() { |
||||
Assert.assertEquals(SecurityKit.passwordEncode("1234"), CommonCodeUtils.passwordEncode("1234")); |
||||
} |
||||
|
||||
@Test |
||||
public void aes() { |
||||
String seed = SecurityKit.createSeed(); |
||||
String text = SecurityKit.aesEncrypt("zed", seed); |
||||
Assert.assertEquals("zed", SecurityKit.aesDecrypt(text, seed)); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue