Search in sources :

Example 1 with FieldMeta

use of com.kyj.fx.voeditor.core.model.meta.FieldMeta in project Gargoyle by callakrsos.

the class FieldMetaFunction method apply.

@Override
public List<FieldMeta> apply(List<TableModelDVO> models) {
    List<FieldMeta> fileMetaList = new ArrayList<>(models.size());
    for (TableModelDVO tableModel : models) {
        try {
            String fieldName = tableModel.getName();
            String type = tableModel.getType();
            FieldMeta fieldMeta = ClassTypeResourceLoader.getInstance().get(type);
            fieldMeta.setName(fieldName);
            fieldMeta.setModifier(Modifier.PRIVATE);
            if ("Y".equals(tableModel.getPk())) {
                fieldMeta.setPrimarykey(true);
            }
            fileMetaList.add(fieldMeta);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return fileMetaList;
}
Also used : FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) ArrayList(java.util.ArrayList) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)

Example 2 with FieldMeta

use of com.kyj.fx.voeditor.core.model.meta.FieldMeta in project Gargoyle by callakrsos.

the class SimpleTest method test.

@Test
public void test() throws Exception {
    FieldMeta fieldMeta = new FieldMeta((Modifier.PRIVATE), "sample", String.class);
    fieldMeta.setPrimarykey(true);
    fieldMeta.setAlias("키속성");
    FieldMeta fieldMeta2 = new FieldMeta((Modifier.PRIVATE), "sample2", String.class);
    FieldMeta fieldMeta3 = new FieldMeta((Modifier.PRIVATE), "check", boolean.class);
    FieldMeta fieldMeta4 = new FieldMeta((Modifier.PRIVATE), "count", int.class);
    FieldMeta fieldMeta5 = new FieldMeta((Modifier.PRIVATE), "name", StringProperty.class, SimpleStringProperty.class);
    FieldMeta fieldMeta6 = new FieldMeta((Modifier.PRIVATE), "name2", StringProperty.class, SimpleStringProperty.class);
    /*
		 * , FxVo.class, new Class<?>[] { IExtractClass .class, IExtractField
		 * .class }
		 */
    ClassMeta classMeta = new ClassMeta("com.sample", "Simple");
    VoEditor voEditor = new VoEditor(classMeta, fieldMeta, fieldMeta2, fieldMeta3, fieldMeta4, fieldMeta5, fieldMeta6);
    voEditor.build();
    String text = voEditor.toText();
    LOGGER.debug(text);
}
Also used : FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) VoEditor(com.kyj.fx.voeditor.core.VoEditor) Test(org.junit.Test)

Example 3 with FieldMeta

use of com.kyj.fx.voeditor.core.model.meta.FieldMeta in project Gargoyle by callakrsos.

the class BaseFxExtractConstructor method work.

@Override
public void work(FxVo vo, ClassMeta classMeta, FieldMeta... fieldMetas) {
    StringBuffer constructPart = vo.getConstructPart();
    constructPart.append("\tpublic ").append(classMeta.getName()).append("( ) \n");
    constructPart.append("\t{ \n");
    for (FieldMeta meta : fieldMetas) {
        try {
            this.extract(vo, meta);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    constructPart.append("\t} \n");
}
Also used : FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta)

Example 4 with FieldMeta

use of com.kyj.fx.voeditor.core.model.meta.FieldMeta in project Gargoyle by callakrsos.

the class DaoWizardViewController method btnGenerateOnMouseClick.

/**
	 * DAO Wizard 생성 버튼 이벤트
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2015. 10. 28.
	 */
@FXML
public void btnGenerateOnMouseClick(MouseEvent event) {
    try {
        int checkValidation = checkValidation();
        String className = txtClassName.getText();
        String location = txtDaoLocation.getText();
        String packageName = txtPackageName.getText();
        String desc = txtAreaDaoDesc.getText();
        // 저장처리전 검증 및 위자드로 한번 확인
        String extendsBaseClass = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.DAO_WIZARD_DEFAULT_EXTENDS_CLASS);
        ClassMeta classMeta = EditorUtil.extractedClassMeta(className, packageName, extendsBaseClass);
        classMeta.setDesc(desc);
        // TbmSysDaoDVO tbmSysDaoDVO = tbmSysDaoDVOProperty.get();
        // tbmSysDaoDVO.setClassName(className);
        // tbmSysDaoDVO.setLocation(location);
        // tbmSysDaoDVO.setPackageName(packageName);
        // tbmSysDaoDVO.setDesc(desc);
        // tbmSysDaoDVO.setExtendClassNameStr(extendsBaseClass);
        DaoWizardConverter converter = new DaoWizardConverter(classMeta, tbmSysDaoDVOProperty.get());
        converter.createWizard(Wizardtype.meerkatbase);
        DaoWizard<ClassMeta, TbpSysDaoMethodsDVO, FieldMeta> daowizard = converter.convert();
        if (location != null && !location.isEmpty()) {
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일생성여부", "파일도 만드시겠습니까? ");
            showYesOrNoDialog.ifPresent(string -> {
                if ("Y".equals(string.getValue())) {
                    try {
                        daowizard.toFile(ValueUtil.appendBaseDir(location));
                    } catch (Exception e) {
                        DialogUtil.showExceptionDailog(e);
                    }
                }
            });
        }
        // 위의 검증작업에서 이상없을시 데이터베이스 저장작업
        if (checkValidation == MESSAGE_CODES.indexOf(MSG_NOMAL)) {
            JavaTextView simpleTextView = new JavaTextView(daowizard.toText());
            simpleTextView.show();
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog(MESSAGE_CODES.get(checkValidation), "Code : [" + checkValidation + "]\n" + MESSAGE_CODES.get(checkValidation) + "\nDo you want save. ?");
            showYesOrNoDialog.ifPresent(option -> {
                if ("Y".equals(option.getValue())) {
                    TbmSysDaoDVO saveTbmSysDaoDVO = this.tbmSysDaoDVOProperty.get();
                    saveTbmSysDaoDVO.setClassName(className);
                    saveTbmSysDaoDVO.setLocation(location);
                    saveTbmSysDaoDVO.setPackageName(packageName);
                    saveTbmSysDaoDVO.setClassDesc(desc);
                    saveTbmSysDaoDVO.setExtendsClassName(extendsBaseClass);
                    save(saveTbmSysDaoDVO);
                }
            });
        } else {
            DialogUtil.showMessageDialog("Error Code[" + checkValidation + "]\n" + MESSAGE_CODES.get(checkValidation));
        }
    // if (checkValidation == MESSAGE_CODES.indexOf(MSG_NOMAL)) {
    //
    // } else {
    // DialogUtil.showMessageDialog(MESSAGE_CODES.get(checkValidation));
    // }
    } catch (Exception e) {
        DialogUtil.showExceptionDailog(e, e.getMessage());
    }
}
Also used : TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) TbmSysDaoDVO(kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO) DaoWizardConverter(com.kyj.fx.voeditor.visual.util.DaoWizardConverter) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) IOException(java.io.IOException) Pair(javafx.util.Pair) FXML(javafx.fxml.FXML)

Example 5 with FieldMeta

use of com.kyj.fx.voeditor.core.model.meta.FieldMeta in project Gargoyle by callakrsos.

the class ClassTypeResourceLoader method get.

public FieldMeta get(String key) throws ClassNotFoundException {
    String property = properties.getProperty(key);
    FieldMeta fieldMeta = null;
    if (property == null) {
        // return null;
        throw new IllegalArgumentException("Key Value not found!");
    }
    if (property.indexOf('!') < 0) {
        Class<?> instanceClass = Class.forName(property);
        fieldMeta = new FieldMeta(instanceClass);
        if (fieldMeta == null) {
            String msg = String.format("Could not create meta instance... type : %s instance %s", instanceClass);
            throw new IllegalStateException(msg);
        }
    } else {
        String[] split = property.split("!");
        String _typeClass = split[0];
        String _instanceClass = split[1];
        Class<?> typeClass = Class.forName(_typeClass);
        Class<?> instanceClass = Class.forName(_instanceClass);
        fieldMeta = new FieldMeta(typeClass, instanceClass);
        if (fieldMeta == null) {
            String msg = String.format("Could not create meta instance... type : %s instance %s", _typeClass, _instanceClass);
            throw new IllegalStateException(msg);
        }
    }
    return fieldMeta;
}
Also used : FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta)

Aggregations

FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)8 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)4 Test (org.junit.Test)3 VoEditor (com.kyj.fx.voeditor.core.VoEditor)2 ArrayList (java.util.ArrayList)2 TbpSysDaoMethodsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO)2 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 Node (com.github.javaparser.ast.Node)1 PackageDeclaration (com.github.javaparser.ast.PackageDeclaration)1 JavaTextView (com.kyj.fx.voeditor.visual.component.popup.JavaTextView)1 DaoWizardConverter (com.kyj.fx.voeditor.visual.util.DaoWizardConverter)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 FXML (javafx.fxml.FXML)1 Pair (javafx.util.Pair)1 DaoWizard (kyj.Fx.dao.wizard.DaoWizard)1 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)1 TbmSysDaoDVO (kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO)1 TbpSysDaoColumnsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO)1 TbpSysDaoFieldsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)1