diff --git a/business-entity-generator-exception/pom.xml b/business-entity-generator-exception/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f91b61538a6df18aa4450dfd63f36668fbc536ba --- /dev/null +++ b/business-entity-generator-exception/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + com.inspur.edp + business-entity-generator1 + 0.1.0-SNAPSHOT + + business-entity-generator-exception + + + + io.iec.edp + caf-commons-exception + + + diff --git a/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationErrorCodeConst.java b/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationErrorCodeConst.java new file mode 100644 index 0000000000000000000000000000000000000000..462dcda57f1e4ac29758f92b9e9e6d679e3380a6 --- /dev/null +++ b/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationErrorCodeConst.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bef.generator.exception; + +public class BefGenerationErrorCodeConst { + /** + * 属性名不存在:[{0}] + */ + public static final String GSP_BEF_GENERATION_0001 = "GSP_BEF_GENERATION_0001"; + /** + * 不存在子表:[{0}] + */ + public static final String GSP_BEF_GENERATION_0002 = "GSP_BEF_GENERATION_0002"; + /** + * 找不到节点,节点编号:[{0}] + */ + public static final String GSP_BEF_GENERATION_0003 = "GSP_BEF_GENERATION_0003"; + /** + * 索引数组中不存在当前值:[{0}] + */ + public static final String GSP_BEF_GENERATION_0004 = "GSP_BEF_GENERATION_0004"; + /** + * udt数据序列化失败 + */ + public static final String GSP_BEF_GENERATION_0005 = "GSP_BEF_GENERATION_0005"; + /** + * 克隆失败 + */ + public static final String GSP_BEF_GENERATION_0006 = "GSP_BEF_GENERATION_0006"; + /** + * 不存在子对象:[{0}] + */ + public static final String GSP_BEF_GENERATION_0007 = "GSP_BEF_GENERATION_0007"; + /** + * 动态属性不允许赋值 + */ + public static final String GSP_BEF_GENERATION_0008 = "GSP_BEF_GENERATION_0008"; + /** + * 变更集类型不正确 + */ + public static final String GSP_BEF_GENERATION_0009 = "GSP_BEF_GENERATION_0009"; + /** + * 只读内容不能变更 + */ + public static final String GSP_BEF_GENERATION_0010 = "GSP_BEF_GENERATION_0010"; + /** + * 数据反序列化失败 + */ + public static final String GSP_BEF_GENERATION_0011 = "GSP_BEF_GENERATION_0011"; +} diff --git a/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationException.java b/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationException.java new file mode 100644 index 0000000000000000000000000000000000000000..7d5901ec5d32703a8bd03529315dac56ac032a90 --- /dev/null +++ b/business-entity-generator-exception/src/main/java/com/inspur/edp/bef/generator/exception/BefGenerationException.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bef.generator.exception; + +import io.iec.edp.caf.commons.exception.CAFRuntimeException; +import io.iec.edp.caf.commons.exception.ExceptionLevel; + +import java.util.Arrays; + +public class BefGenerationException extends CAFRuntimeException { + private static final String SERVICE_UNIT_CODE = "pfcommon"; + private static final String RESOURCE_FILE = "business_entity_generator_exception.properties"; + + public BefGenerationException(Throwable innerException, String exceptionCode, Object... messageParams) { + super(SERVICE_UNIT_CODE, RESOURCE_FILE, exceptionCode, + Arrays.stream(messageParams).map(String::valueOf).toArray(String[]::new), + innerException, ExceptionLevel.Error, false); + } +} diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/dataserializer/deserialize/GetChildDeserConvertorGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/dataserializer/deserialize/GetChildDeserConvertorGenerator.java index fbc37ced3fa7e1f7ce08f19fbd901b92fe8f1105..c471f6fe9fcf2c568b827a8a35a943437bdd400f 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/dataserializer/deserialize/GetChildDeserConvertorGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/dataserializer/deserialize/GetChildDeserConvertorGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.dataserializer.deserialize; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.bef.spi.entity.AbstractBizEntityDeSerializer; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.deserializer.EntityDataDeserGenCtx; import com.inspur.edp.cef.generator.overall.GeneratorUtil; @@ -56,11 +57,10 @@ public class GetChildDeserConvertorGenerator extends ClassMethodGenerator { } private void buildThowExceptionStatement(Block block) { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement=GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, paramChildCode); block.statements().add(throwStatement); } diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/entityimpl/BefEntityImplGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/entityimpl/BefEntityImplGenerator.java index 110c969c298b1d37919e6c5a78fd4084642f65aa..ddd294e96748c9a6f0af74fd7be70f84a738bc35 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/entityimpl/BefEntityImplGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/entityimpl/BefEntityImplGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.entityimpl; @@ -41,8 +41,6 @@ import com.inspur.edp.caf.generator.field.FieldGenerator; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.property.ClassPropertyGenerator; import com.inspur.edp.cef.gencommon.MediateType; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.ReadonlyRootAcsGenerator; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.RootAcsGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen.RootDualAcsGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.DataTypeImpContext; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityDataImplGenerator; @@ -50,7 +48,6 @@ import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGenerator import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityImplGenerator; import com.inspur.edp.das.commonmodel.IGspCommonObject; import java.util.ArrayList; -import org.hibernate.annotations.Parent; /** * BE节点生成器基类 @@ -140,8 +137,6 @@ public abstract class BefEntityImplGenerator extends EntityImplGenerator { return result; } - //region dtm/val Assembler - @Override protected ClassMethodGenerator getCreateAfterModifyDtmAssMethodGenerator() { return new BefCreateAfterModifyDtmAssMethodGenerator(getBefEntityImplContext(), node.getCode()); @@ -179,17 +174,4 @@ public abstract class BefEntityImplGenerator extends EntityImplGenerator { protected FieldGenerator getDataTypeCacheInfoFieldGenerator() { return new GetCacheInfoFieldGenerator(); } - - //endregion - -// @Override -// protected ArrayList createClassExtendChildGenrators() { -// ArrayList baseExtendGens = super.createClassExtendChildGenrators(); -// if (baseExtendGens == null) { -// baseExtendGens = new ArrayList(); -// } -// baseExtendGens.add(new BeDtmsGenerator(getBefEntityImplContext())); -// baseExtendGens.add(new BeValidationsGenerator(getBefEntityImplContext())); -// return baseExtendGens; -// } } diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildAccessorGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildAccessorGenerator.java index 04a805e95659594eaa3bc32aec46f978e45963ce..096d9930052fd6ea07e49cf0996d7058fa2897c9 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildAccessorGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildAccessorGenerator.java @@ -1,32 +1,41 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.method; import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.entityimpl.BefEntityImplGenCtx; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; import com.inspur.edp.cef.api.attr.ChildEntityAttribute; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.entity.IEntityData; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.CastExpression; +import org.eclipse.jdt.core.dom.ClassInstanceCreation; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.SwitchCase; +import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; import java.util.HashMap; import java.util.Map; @@ -97,21 +106,13 @@ public class CreateChildAccessorGenerator extends ClassMethodGenerator SwitchCase switchCase=ast.newSwitchCase(); switchCase.setExpression(null); switchStatement.statements().add(switchCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement=GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement=GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, paramChildCode); switchStatement.statements().add(throwStatement); } -// private void addRootNodeCase(SwitchStatement switchStatement) { -// SwitchCase switchCase=ast.newSwitchCase(); -// switchCase.setExpression(ExpressionUtils.getStringLiteral(ast,"RootNode")); -// switchStatement.statements().add(switchCase); -// switchStatement.statements().add(buildReturnAccessorStatement()) -// } - private ReturnStatement buildReturnAccessorStatement(String accessorClassName,String dataClassName) { ReturnStatement returnStatement=ast.newReturnStatement(); diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildEntityDataGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildEntityDataGenerator.java index eb5e97a07cd3529c59b2825b068c444a2d62f69a..4badaeebba159b8738295e739f041dca6661c785 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildEntityDataGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/CreateChildEntityDataGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.method; @@ -19,11 +19,12 @@ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.method; import com.inspur.edp.bef.bizentity.GspBizEntityElement; import com.inspur.edp.bef.bizentity.GspBizEntityObject; import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.entityimpl.BefEntityImplGenCtx; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; import com.inspur.edp.cef.entity.entity.IEntityData; @@ -226,12 +227,10 @@ public class CreateChildEntityDataGenerator extends ClassMethodGenerator { SwitchCase switchCase = ast.newSwitchCase(); switchCase.setExpression(null); switchStatement.statements().add(switchCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, paramchildCode); switchStatement.statements().add(throwStatement); } } diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/GetChildBEEntityGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/GetChildBEEntityGenerator.java index 20a387857482dfc1cd084ece5c46415a35dd1a0e..ad9be16ba07bcee036e5053c4777821cd572096a 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/GetChildBEEntityGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/entitygen/method/GetChildBEEntityGenerator.java @@ -1,41 +1,40 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.method; import com.inspur.edp.bef.core.be.BENodeEntity; import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.entityimpl.BefEntityImplGenCtx; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.attr.ChildEntityAttribute; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.das.commonmodel.IGspCommonObject; import java.util.ArrayList; import java.util.HashMap; -import java.util.Map; + import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.ReturnStatement; -import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.SwitchCase; import org.eclipse.jdt.core.dom.SwitchStatement; import org.eclipse.jdt.core.dom.ThrowStatement; @@ -188,12 +187,10 @@ for (IGspCommonObject childNode : node.getContainChildObjects()) { SwitchCase case1 = ast.newSwitchCase(); case1.setExpression(null); switchStatement.statements().add(case1); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, paramchildCode); switchStatement.statements().add(throwStatement); } } diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BeMgrClassGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BeMgrClassGenerator.java index 54edd45a29b11e22d3c5382e963c35e7b20b6b82..0f88996ba54a80cc65183e185dcecee84a2aea42 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BeMgrClassGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BeMgrClassGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.managergen; @@ -26,20 +26,13 @@ import com.inspur.edp.bef.dtgenerator.core.BefCoreGenCtx; import com.inspur.edp.bef.dtgenerator.core.mgrImpl.mgrMethods.MgrImpDeleteGenerator; import com.inspur.edp.bef.dtgenerator.core.mgrImpl.mgrMethods.MgrImpRetrieveGenerator; import com.inspur.edp.bef.dtgenerator.core.mgrImpl.mgrMethods.MgrImplMethodGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.changeserializer.BefEntityDataChangeSerGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.dataserializer.serializer.BefEntityDataSerializerGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.field.BefManagerCacheInfoFieldGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.CreateB4QueryDtmAssemblerGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.CreateEntityGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetChangeDeserializerGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetChangeSerializerGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetCreateVarMgrGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetDataDeserializerGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetDataSerializerGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetManagerCacheInfoGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.GetModelInfosMethodGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.managergen.method.createBeforeRetrieveDtmAssembler; -import com.inspur.edp.caf.generator.BaseGenerator; import com.inspur.edp.caf.generator.field.FieldGenerator; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.cef.gencommon.MediateType; diff --git a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BefManagerGenerator.java b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BefManagerGenerator.java index 8b5d715d1eb20fa93ed6a2b33eed8b0232b5919a..e4204c9f7c1cc57f880b200f874da463089ad827 100644 --- a/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BefManagerGenerator.java +++ b/business-entity-generator/src/main/java/com/inspur/edp/bef/dtgenerator/core/rtgen/managergen/BefManagerGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.bef.dtgenerator.core.rtgen.managergen; @@ -20,10 +20,8 @@ import com.inspur.edp.bef.dtgenerator.core.BefCoreGenCtx; import com.inspur.edp.bef.dtgenerator.core.rtgen.accessorcreatorgen.BefAccessorCreatorGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.BefEntityGenerator; import com.inspur.edp.bef.dtgenerator.core.rtgen.lcpgenerator.LcpClassGenerator; -import com.inspur.edp.bef.dtgenerator.core.rtgen.variable.BEVariableGenerator; import com.inspur.edp.caf.generator.BaseGenerator; import com.inspur.edp.caf.generator.composite.CompositeGeneratorContext; -import com.inspur.edp.cef.designtime.api.variable.CommonVariableEntity; import com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.AccessorCreatorGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.DataManagerImplGenerator; diff --git a/common-entity-generator/pom.xml b/common-entity-generator/pom.xml index 0084b8d7da55614219385ad44cdff23f485dccc6..a2679779350118f69d66a5150fc9965fb07e589e 100644 --- a/common-entity-generator/pom.xml +++ b/common-entity-generator/pom.xml @@ -15,20 +15,6 @@ ~ limitations under the License. --> - - @@ -42,6 +28,10 @@ common-entity-generator + + com.inspur.edp + business-entity-generator-exception + com.inspur.edp caf-generator @@ -73,16 +63,16 @@ com.inspur.edp lcm-database-object-api - - com.inspur.edp - common-entity-framework-api - - - com.inspur.edp - cef-api - - - + + + + + + + + + + com.inspur.edp common-entity-framework-spi diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildAccessorGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildAccessorGenerator.java index 3124ba373c79cbd36691aacf2fc8a8fc07a0c67f..ea64c85032d5a18e56412ac237460cb322e7ff11 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildAccessorGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildAccessorGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.accessor.base.IAccessor; import com.inspur.edp.cef.entity.entity.ICefData; import com.inspur.edp.cef.gencommon.MediateType; @@ -92,34 +93,13 @@ public class CreateChildAccessorGenerator extends ClassMethodGenerator return block; } - private void addDefaultCaseStatement(SwitchStatement switchStatement) - { -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// setExceptionCode.addExceptionCodeMessage(switchStatement,ast,"找不到节点,节点编号:",ParName_Code); - + private void addDefaultCaseStatement(SwitchStatement switchStatement) { SwitchCase switchCase=ast.newSwitchCase(); switchCase.setExpression(null); switchStatement.statements().add (switchCase); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"找不到节点,节点编号",ParName_Code,true); - addImport(CefException.class.getTypeName()); -// ClassInstanceCreation classInstanceCreation =ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"找不到节点,节点编号",ParName_Code); - //CefException cefException = new CefException("","找不到节点,节点编号",new RuntimeException(), ExceptionLevel.Error); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(CefException.class).getType(ast)); -// InfixExpression infixExpression=ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral =ast.newStringLiteral(); -// stringLiteral.setLiteralValue("找不到节点,节点编号:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(ParName_Code)); -// classInstanceCreation.arguments().add(infixExpression); - -// InfixExpression errorCode=ast.newInfixExpression(); -// stringLiteral.setLiteralValue(ErrorCodes.Exception_Code); -// errorCode.setLeftOperand(stringLiteral); -// classInstanceCreation.arguments().add(errorCode); - -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0003, ParName_Code); switchStatement.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildReadonlyAccessorGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildReadonlyAccessorGenerator.java index 67d4f2e4931013a83fcaf17f5b48207d479f7eb0..dd985c1c928cab9acf4e1e50a5a6e0244b2c932f 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildReadonlyAccessorGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorcreatorgen/method/CreateChildReadonlyAccessorGenerator.java @@ -1,25 +1,26 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.accessor.base.IAccessor; import com.inspur.edp.cef.entity.entity.ICefData; import com.inspur.edp.cef.gencommon.MediateType; @@ -89,26 +90,13 @@ public class CreateChildReadonlyAccessorGenerator extends ClassMethodGenerator return block; } - private void addDefaultCaseStatement(SwitchStatement switchStatement) - { -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// setExceptionCode.addExceptionCodeMessage(switchStatement,ast,"找不到节点,节点编号:",ParName_Code); + private void addDefaultCaseStatement(SwitchStatement switchStatement) { SwitchCase switchCase=ast.newSwitchCase(); switchCase.setExpression(null); switchStatement.statements().add(switchCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"找不到节点,节点编号:",ParName_Code,true); -// ClassInstanceCreation classInstanceCreation =ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"找不到节点,节点编号:",ParName_Code); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// InfixExpression infixExpression=ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral =ast.newStringLiteral(); -// stringLiteral.setLiteralValue("找不到节点,节点编号:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(ParName_Code)); -// classInstanceCreation.arguments().add(infixExpression); - //throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0003, ParName_Code); switchStatement.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorAcceptChangeGen.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorAcceptChangeGen.java index 5c9586d02b5112c3a18fb784d3c73d731f8e3989..6b4bb59820681db60e42775744a1fe019f5d4391 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorAcceptChangeGen.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorAcceptChangeGen.java @@ -1,27 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; -import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; import com.inspur.edp.cef.entity.accessor.base.IAccessor; @@ -39,7 +39,6 @@ import lombok.var; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.CastExpression; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.EnhancedForStatement; import org.eclipse.jdt.core.dom.ExpressionStatement; import org.eclipse.jdt.core.dom.IfStatement; @@ -122,22 +121,15 @@ public class AccessorAcceptChangeGen extends ClassMethodGenerator { ifStatement.setExpression(infixExpression); Block blockStatement = ast.newBlock(); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0009); blockStatement.statements().add(throwStatement); - addImport(CefException.class.getTypeName()); ifStatement.setThenStatement(blockStatement); block.statements().add(ifStatement); } - /*ModifyChangeDetail val =null; - for(Map.Entry propertyChange:val.getPropertyChanges().entrySet()) - { - switch (propertyChange.getKey()) - { - - } - }*/ private void addSetChangePropValuesStatement(Block block) { EnhancedForStatement forStatement = ast.newEnhancedForStatement(); addSetChangeProForParameter(forStatement); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorCreateAndSetChildCollectionGen.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorCreateAndSetChildCollectionGen.java index 68d1ba0cb94394a1272b201afb0f5c14978364f0..df2cab758ec2ef532780a5f9dc6621a89660c5c3 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorCreateAndSetChildCollectionGen.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AccessorCreateAndSetChildCollectionGen.java @@ -1,32 +1,42 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.core.data.AccessorCollection; import com.inspur.edp.cef.entity.entity.IEntityDataCollection; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClassTypeInfo; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.das.commonmodel.IGspCommonObject; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Assignment; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.ExpressionStatement; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import java.util.ArrayList; @@ -173,47 +183,10 @@ public class AccessorCreateAndSetChildCollectionGen extends ClassMethodGenerator } private void addDefaultThrowStatement(Block block) { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"",""); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); - + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, FormalParName); block.statements().add(throwStatement); } - -// @Override -// protected Block buildMethodBody() -// { - -// var propSwitchStatement = SyntaxFactory.SwitchStatement(SyntaxFactory.IdentifierName(FormalParName)); - -// for (var prop : propertyInfos) -// { - -// var childAttr = prop.getCustomAttribute(); -// if (childAttr == null) -// { -// continue; -// } -// propSwitchStatement = propSwitchStatement.AddSections(getChildPropSection(childAttr)); -// } -// propSwitchStatement = propSwitchStatement.AddSections(getDefaultSection()); -// return SyntaxFactory.Block(SyntaxFactory.SingletonList(propSwitchStatement)); -// } -// -// -// private SwitchSectionSyntax getChildPropSection(ChildAttribute childAttr) -// { -// //SyntaxFactory.Token(SyntaxKind.CommaToken), -// //SyntaxFactory.Argument( -// // SyntaxFactory.ThisExpression()) -// return SyntaxFactory.SwitchSection().WithLabels(SyntaxFactory.SingletonList(SyntaxFactory.CaseSwitchLabel(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(childAttr.getObjectCode()))))).WithStatements(SyntaxFactory.List(new StatementSyntax[] { SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, SyntaxFactory.IdentifierName(childNodeFields.get(childAttr.getObjectCode())), SyntaxFactory.ObjectCreationExpression(SyntaxFactory.ParseName(accessorTypeInfo.getChildObjAccessorCollectionTypes().get(childAttr.getObjectCode()).FullName)).WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(new SyntaxNodeOrToken[] { SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)) }))).WithInitializer(SyntaxFactory.InitializerExpression(SyntaxKind.ObjectInitializerExpression, SyntaxFactory.SingletonSeparatedList(SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, SyntaxFactory.IdentifierName("Parent"), SyntaxFactory.ThisExpression())))))), SyntaxFactory.ReturnStatement(SyntaxFactory.CastExpression(TypeUtils.getTypeSyntax(IEntityDataCollection.class), SyntaxFactory.IdentifierName(childNodeFields.get(childAttr.getObjectCode())))) })); -// } -// -// private SwitchSectionSyntax getDefaultSection() -// { -// return SyntaxFactory.SwitchSection().WithLabels(SyntaxFactory.SingletonList(SyntaxFactory.DefaultSwitchLabel())).WithStatements(SyntaxFactory.SingletonList(SyntaxFactory.ThrowStatement(SyntaxFactory.ObjectCreationExpression(TypeUtils.getTypeSyntax(ArgumentOutOfRangeException.class)).WithArgumentList(SyntaxFactory.ArgumentList())))); -// } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AcsCreateChildGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AcsCreateChildGenerator.java index 3a1287dc36d01a399f1f5c99f579cc1a0bc2e9a9..1ef28119775ca52d7403fcbca1201867101fc0f3 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AcsCreateChildGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/AcsCreateChildGenerator.java @@ -1,38 +1,47 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.entity.entity.ICefData; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClassGenContext; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.das.commonmodel.IGspCommonObject; import java.util.HashMap; -import org.eclipse.jdt.core.dom.*; import java.util.ArrayList; import java.util.Map; + +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.CastExpression; +import org.eclipse.jdt.core.dom.ClassInstanceCreation; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; public class AcsCreateChildGenerator extends ClassMethodGenerator { @@ -147,20 +156,10 @@ public class AcsCreateChildGenerator extends ClassMethodGenerator methodInvocation.setExpression(innerInvocation); } - private void addThrowNotSupportChildCodeException(Block block) - { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"不存在子表",varChildCode,true); - //setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"不存在子表",varChildCode); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); - -// InfixExpression infixExpression=ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral=ast.newStringLiteral(); -// stringLiteral.setLiteralValue("不存在子表"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(varChildCode)); -// classInstanceCreation.arguments().add(infixExpression); + private void addThrowNotSupportChildCodeException(Block block) { + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0002, varChildCode); block.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ChildAccessorAcceptChangeGen.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ChildAccessorAcceptChangeGen.java index 3ed4221f0b1d78533c0394689c7e3fdfd91cfe58..7160ad45ddf3dd585b2cfc8cf8762a18a0485d46 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ChildAccessorAcceptChangeGen.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ChildAccessorAcceptChangeGen.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.changeset.AddChangeDetail; import com.inspur.edp.cef.entity.changeset.DeleteChangeDetail; import com.inspur.edp.cef.entity.changeset.IChangeDetail; @@ -32,7 +33,22 @@ import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClass import java.util.List; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.CastExpression; +import org.eclipse.jdt.core.dom.EnhancedForStatement; +import org.eclipse.jdt.core.dom.ExpressionStatement; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.InfixExpression; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ParameterizedType; +import org.eclipse.jdt.core.dom.ParenthesizedExpression; +import org.eclipse.jdt.core.dom.SingleVariableDeclaration; +import org.eclipse.jdt.core.dom.SuperMethodInvocation; +import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import java.util.ArrayList; import java.util.Map; @@ -454,14 +470,10 @@ public class ChildAccessorAcceptChangeGen extends ClassMethodGenerator } //throw new RuntimeException(); - private void addThrowStatements(Block block) - { -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"",""); - //classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatement(ast,null); + private void addThrowStatements(Block block) { + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0009); block.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/NestedAccessorAcceptChangeGen.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/NestedAccessorAcceptChangeGen.java index d7633be6d8d92cf27e80e60b39e2a62a46c691b1..93dfc17878ee412e9bfda7af9b597e6df9172ccf 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/NestedAccessorAcceptChangeGen.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/NestedAccessorAcceptChangeGen.java @@ -1,24 +1,25 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.entity.changeset.ValueObjModifyChangeDetail; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; @@ -93,14 +94,11 @@ public class NestedAccessorAcceptChangeGen extends AccessorAcceptChangeGen infixExpression.setRightOperand(ast.newNullLiteral()); ifStatement.setExpression(infixExpression); - addImport(CefException.class.getTypeName()); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); Block blockStatement = ast.newBlock(); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"",""); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0009); + blockStatement.statements().add(throwStatement); ifStatement.setThenStatement(blockStatement); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ReadOnlyAcceptChangeGen.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ReadOnlyAcceptChangeGen.java index b299f6cd6e1e6a3c1aa1c584a2fe4ef4f83bc6b5..140816d587cbd044c4b8dbaa8dba42fd9a392501 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ReadOnlyAcceptChangeGen.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/method/ReadOnlyAcceptChangeGen.java @@ -1,28 +1,31 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.changeset.IChangeDetail; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ThrowStatement; import java.util.ArrayList; @@ -33,13 +36,9 @@ public class ReadOnlyAcceptChangeGen extends ClassMethodGenerator @Override protected Block buildMethodBody() { Block block=ast.newBlock(); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatement(ast,null); -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"",""); -// classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(UnsupportedOperationException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0010); block.statements().add(throwStatement); return block; } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/property/DynamicPropAcsPropertyGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/property/DynamicPropAcsPropertyGenerator.java index 1262bcad83c1c7df7a4dfc2f598e4988ccacd18c..78c6888c4126c92c87abb86c5497da392fc508de 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/property/DynamicPropAcsPropertyGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/accessorgen/property/DynamicPropAcsPropertyGenerator.java @@ -1,26 +1,29 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.property; -import com.inspur.edp.cef.api.message.CefException; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.property.DynamicPropSetPropertyGenerator; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; public class DynamicPropAcsPropertyGenerator extends DynamicPropSetPropertyGenerator { @@ -39,15 +42,10 @@ public class DynamicPropAcsPropertyGenerator extends DynamicPropSetPropertyGener @Override protected Block buildSetMethodBody() { - addImport(CefException.class.getTypeName()); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); Block block = ast.newBlock(); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// SetExceptionCode setExceptionCode =new SetExceptionCode(); -// -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"",""); -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0008); block.statements().add(throwStatement); return block; } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/ChildDualAcsGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/ChildDualAcsGenerator.java index 2e5c794e43573c572078fdd9c93b7c2c6f8b9cfc..ca738fa79e0cef6700a02d5d380d168d0b4e3da5 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/ChildDualAcsGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/ChildDualAcsGenerator.java @@ -1,30 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen; import com.inspur.edp.caf.generator.BaseGenerator; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; -import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.cef.core.data.ChildEntityAccessor; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClassGenContext; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.EntityAcsGenerator; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.ChildAccessorAcceptChangeGen; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.property.ParentIdPropGenerator; import com.inspur.edp.das.commonmodel.IGspCommonObject; diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/DualEntityAcsGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/DualEntityAcsGenerator.java index 22faabc46a2f29fc2f41d361d2e42abdad64a125..7a7cc30fde816afab8b8edd08b8d9c8dfe7026c4 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/DualEntityAcsGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/DualEntityAcsGenerator.java @@ -1,51 +1,44 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen; -import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.item.ClassGeneratorContext; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.property.ClassPropertyGenerator; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorChildClassGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClassGenContext; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.BaseAcsGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AccessorCopySelfGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AccessorCreateAndSetChildCollectionGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AccessorInitializeChildCollectionGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AccessorInitializeNestedGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AccessorInnerChangedGen; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.AcsCreateChildGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.EntityAccessorInitializeGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.GetChildsGenerator; -import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.NewChildCollectionGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.base.AccessorInitializeGen; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.base.AcsCopyGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.method.entity.EntityAcsCopyGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.property.AccessorChildCollectionProperty; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.property.NodeCodeGenerator; -import com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen.method.DualAccCtorGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen.method.DualAcsCreateChildGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen.method.DualNewChildCollectionGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.BaseDataGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext; -import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.field.ChildFieldGenerator; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.property.ChildPropGenerator; import com.inspur.edp.das.commonmodel.IGspCommonObject; import java.util.ArrayList; diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/method/DualAcsCreateChildGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/method/DualAcsCreateChildGenerator.java index 0353b7bd105da298bc9f69201ac893dbc53cfc13..dd34bf8e6c4c8ddb6e82269e64b0937590357aaf 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/method/DualAcsCreateChildGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/dualaccgen/method/DualAcsCreateChildGenerator.java @@ -1,27 +1,28 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.dualaccgen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.entity.entity.ICefData; import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.AccessorClassGenContext; @@ -160,20 +161,9 @@ public class DualAcsCreateChildGenerator extends ClassMethodGenerator { } private void addThrowNotSupportChildCodeException(Block block) { -// SetExceptionCode setExceptionCode = new SetExceptionCode(); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"不存在子表",varChildCode,true); - addImport(CefException.class.getTypeName()); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(classInstanceCreation,ast,"不存在子表",varChildCode); -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("不存在子表"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(varChildCode)); -// classInstanceCreation.arguments().add(infixExpression); - //throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0002, varChildCode); block.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CopySelfGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CopySelfGenerator.java index 9f55fa864068e1ddbb1ef2cbdba112e00a0f4100..f49eb14d3248dec0c9078ffd24c657803a6dbd34 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CopySelfGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CopySelfGenerator.java @@ -1,32 +1,32 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.entity.ICefData; import java.util.ArrayList; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.CastExpression; import org.eclipse.jdt.core.dom.CatchClause; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.ReturnStatement; @@ -93,14 +93,9 @@ public class CopySelfGenerator extends ClassMethodGenerator { private void setCatchClauseBody(CatchClause catchClause) { Block catchBodyBlock = ast.newBlock(); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatementWithParamName(ast,"e"); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// classInstanceCreation.arguments().add(ast.newSimpleName("e")); -// throwStatement.setExpression(classInstanceCreation); - + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, "e", BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0006); catchBodyBlock.statements().add(throwStatement); catchClause.setBody(catchBodyBlock); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CreateValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CreateValueGenerator.java index 89b2ad171db0b2867726edd3dcb1195e3c9d1560..f889160538a7ade49f176b4ef70a0d0898a3ba98 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CreateValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/CreateValueGenerator.java @@ -1,25 +1,26 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext; @@ -28,8 +29,18 @@ import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.generator.overall.Utils; import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef; import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Assignment; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.ClassInstanceCreation; +import org.eclipse.jdt.core.dom.ExpressionStatement; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.dom.SwitchCase; +import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import java.util.ArrayList; import java.util.List; @@ -160,21 +171,9 @@ public class CreateValueGenerator extends ClassMethodGenerator { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"属性名不存在:",param1,true);; -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); - -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("属性名不存在:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(param1)); -// classInstanceCreation.arguments().add(infixExpression); -// -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, param1); switchStatement.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataCreateChildGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataCreateChildGenerator.java index 5f0f4314cf2b3c9f68dc1b29080e0112b93e0c45..c61be8a6028694d8d6649431d23e7efb8e7f0813 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataCreateChildGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataCreateChildGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.entity.ICefData; import java.util.ArrayList; import java.util.Map; @@ -28,12 +29,10 @@ import com.inspur.edp.cef.generator.overall.GeneratorUtil; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.IfStatement; -import org.eclipse.jdt.core.dom.InfixExpression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; import org.eclipse.jdt.core.dom.ReturnStatement; -import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.ThrowStatement; public class DataCreateChildGenerator extends ClassMethodGenerator { @@ -119,20 +118,9 @@ public class DataCreateChildGenerator extends ClassMethodGenerator { } private void addThrowNotSupportChildCodeException(Block block) { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"不存在子表",varChildCode,true); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("不存在子表"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(varChildCode)); -// classInstanceCreation.arguments().add(infixExpression); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0002, varChildCode); block.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticGetValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticGetValueGenerator.java index e0f2f67859ac27732b8cfc4133de1413608d3bb3..da3254d3aa622e0fd731ecc50d0b704273734248 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticGetValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticGetValueGenerator.java @@ -1,35 +1,33 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.gencommon.MediateType; -import com.inspur.edp.cef.generator.common.DataStaticEqualsMethodGenerator; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; -import java.sql.ParameterMetaData; + import java.util.ArrayList; import java.util.List; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import org.eclipse.jdt.core.dom.Block; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; -import org.eclipse.jdt.core.dom.InfixExpression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; @@ -132,22 +130,9 @@ public class DataStaticGetValueGenerator extends ClassMethodGenerator { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"属性名不存在:",FormalParName,true); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("属性名不存在:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(FormalParName)); -// classInstanceCreation.arguments().add(infixExpression); -// -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, FormalParName); switchStatement.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticSetValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticSetValueGenerator.java index 17491cc52b8466c592de715076ad5664cb1f3de2..bd83e5e2e2557d2e2e3fd37092f882d9c2d955be 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticSetValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/DataStaticSetValueGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.common.MediatePropertyInfo; @@ -35,7 +36,6 @@ import java.util.List; import lombok.var; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.CastExpression; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.ExpressionStatement; import org.eclipse.jdt.core.dom.IfStatement; import org.eclipse.jdt.core.dom.InfixExpression; @@ -264,8 +264,6 @@ public class DataStaticSetValueGenerator extends ClassMethodGenerator { CastExpression castExpression = ast.newCastExpression(); castExpression.setType(propertyInfo.getPropertyType().getType(ast)); - //castExpression.setType(ast.newSimpleType(ast.newName(propertyType.getTypeName()))); - //castExpression.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(byte[].class).getType(ast)); castExpression.setExpression(ast.newSimpleName(param2)); methodInvocation.arguments().add(castExpression); methodInvocation.setExpression(ast.newSimpleName(ParData)); @@ -278,22 +276,9 @@ public class DataStaticSetValueGenerator extends ClassMethodGenerator { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"属性名不存在:",param1,true); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("属性名不存在:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(param1)); -// classInstanceCreation.arguments().add(infixExpression); -// -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, param1); switchStatement.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/MergeChildDataGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/MergeChildDataGenerator.java index 8da31ab6e33ac9c6556b2d16734786868d7f5c1a..701669ecc15e4c13a023efa00d646b222d9cde38 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/MergeChildDataGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/MergeChildDataGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.entity.entity.IEntityData; import com.inspur.edp.cef.gencommon.MediateType; import java.util.ArrayList; @@ -28,16 +29,13 @@ import java.util.HashMap; import java.util.Map; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import org.eclipse.jdt.core.dom.Block; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.EnhancedForStatement; import org.eclipse.jdt.core.dom.ExpressionStatement; import org.eclipse.jdt.core.dom.IfStatement; -import org.eclipse.jdt.core.dom.InfixExpression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; -import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.ThrowStatement; public class MergeChildDataGenerator extends ClassMethodGenerator { @@ -166,20 +164,9 @@ public class MergeChildDataGenerator extends ClassMethodGenerator { } private void addThrowNotSupportChildCodeException(Block block) { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"不存在子表",formalParNodeCode,true); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("不存在子表"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(formalParNodeCode)); -// classInstanceCreation.arguments().add(infixExpression); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0002, formalParNodeCode); block.statements().add(throwStatement); } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/copy/CopyMethodGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/copy/CopyMethodGenerator.java index 8e30a3fe5d3936ed80cf092c2665cbdd6e16b679..126176141d20800e7c613ffe68dd7001aa8e9858 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/copy/CopyMethodGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/entitygen/method/copy/CopyMethodGenerator.java @@ -1,26 +1,27 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method.copy; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.core.data.EntityDataCollection; @@ -33,7 +34,7 @@ import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityDataUtils import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext; import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method.GetResInfoGenerator; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import com.inspur.edp.das.commonmodel.IGspCommonObject; + import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.core.dom.Assignment; @@ -114,14 +115,9 @@ public class CopyMethodGenerator extends ClassMethodGenerator { private void setCatchClauseBody(CatchClause catchClause) { Block catchBodyBlock = ast.newBlock(); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatementWithParamName(ast,"e"); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType( -// new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// classInstanceCreation.arguments().add(ast.newSimpleName("e")); -// throwStatement.setExpression(classInstanceCreation); - + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, "e", BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0006); catchBodyBlock.statements().add(throwStatement); catchClause.setBody(catchBodyBlock); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/serializer/changeser/entity/deserializer/NodeDataChangeGetChildGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/serializer/changeser/entity/deserializer/NodeDataChangeGetChildGenerator.java index 36ad0e7268b3c17ec199106fa95122cb2a122e09..3c0ee451e34eaf60d1ee31feb609d458c1fb986a 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/serializer/changeser/entity/deserializer/NodeDataChangeGetChildGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/coreGenerator/base/serializer/changeser/entity/deserializer/NodeDataChangeGetChildGenerator.java @@ -1,30 +1,38 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.coreGenerator.base.serializer.changeser.entity.deserializer; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.gencommon.MediateType; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntityChangeJsonDeSerializer; import com.inspur.edp.cef.spi.jsonser.util.SerializerUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.ClassInstanceCreation; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.dom.ThrowStatement; import java.util.ArrayList; import java.util.Map; @@ -47,11 +55,10 @@ public class NodeDataChangeGetChildGenerator extends ClassMethodGenerator { } private void buildThowExceptionStatement(Block block) { - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement=GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0007, paramNodeCode); block.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/EnumForValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/EnumForValueGenerator.java index a1200ed20ef725cf54cd787d6a7521f7979dd002..2df312953faba15b4e0f775a5ee9034949c1462a 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/EnumForValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/EnumForValueGenerator.java @@ -1,29 +1,36 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.entityGenerator.base.elements; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.designtime.api.element.EnumIndexType; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.PrefixExpression; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; import java.util.ArrayList; import java.util.Arrays; @@ -44,29 +51,6 @@ public class EnumForValueGenerator extends ClassMethodGenerator { } @Override protected Block buildMethodBody() { -// Block block=ast.newBlock(); -// ReturnStatement returnStatement=ast.newReturnStatement(); -// ArrayAccess arrayAccess=ast.newArrayAccess(); -// -// MethodInvocation methodInvocation=ast.newMethodInvocation(); -// methodInvocation.setName(ast.newSimpleName("values")); -// arrayAccess.setArray(methodInvocation); -// -// arrayAccess.setIndex(ast.newSimpleName("value")); -// -// returnStatement.setExpression(arrayAccess); -// block.statements().add(returnStatement); -// Block block=ast.newBlock(); -// MethodInvocation methodInvocation2 =ast.newMethodInvocation(); -// MethodInvocation methodInvocation3 =ast.newMethodInvocation(); -// methodInvocation3.setName(ast.newSimpleName("getMappings")); -// methodInvocation2.setExpression(methodInvocation3); -// methodInvocation2.setName(ast.newSimpleName("get")); -// methodInvocation2.arguments().add(ast.newSimpleName("value")); -// ReturnStatement returnStatement1=ast.newReturnStatement(); -// returnStatement1.setExpression(methodInvocation2); -// block.statements().add(returnStatement1); - // Block block=ast.newBlock(); IfStatement ifStatement=ast.newIfStatement(); @@ -78,19 +62,9 @@ public class EnumForValueGenerator extends ClassMethodGenerator { MethodInvocation methodInvocation1=ast.newMethodInvocation(); methodInvocation1.setName(ast.newSimpleName("getMappings")); Block block1=ast.newBlock(); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatement(ast,"索引数组中不存在当前值:","value",true); -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// classInstanceCreation.setType(ast.newSimpleType(ast.newSimpleName("RuntimeException"))); -// InfixExpression infixExpression=ast.newInfixExpression(); -// StringLiteral stringLiteral=ast.newStringLiteral(); -// stringLiteral.setLiteralValue("索引数组中不存在当前值:"); -// -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// infixExpression.setRightOperand(ast.newSimpleName("value")); -// classInstanceCreation.arguments().add(infixExpression); -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0004, "value"); block1.statements().add(throwStatement); ifStatement.setThenStatement(block1); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoGetValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoGetValueGenerator.java index 954175c0e14dfd44d387ac80db2e93879f3d1f04..d284c2c0aee73a5e6f69d38e6395aafc25555c55 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoGetValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoGetValueGenerator.java @@ -1,29 +1,37 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.entityGenerator.base.elements.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.property.ClassPropertyGenerator; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.generator.entityGenerator.base.elements.AssoPropertyGenerator; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.dom.SwitchCase; +import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; import java.util.ArrayList; @@ -111,30 +119,13 @@ public class AssoGetValueGenerator extends ClassMethodGenerator { switchStatement.statements().add(returnStatement); } - //endregion - - //region SwitchDefaultCase private void setSwitchDefaultCase(SwitchStatement switchStatement) { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"属性名不存在:",FormalParName,true); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// -// -// InfixExpression infixExpression = ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral = ast.newStringLiteral(); -// stringLiteral.setLiteralValue("属性名不存在:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(FormalParName)); -// classInstanceCreation.arguments().add(infixExpression); -// -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, FormalParName); switchStatement.statements().add(throwStatement); } - //endregion } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoSetValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoSetValueGenerator.java index 555c2ed430aaa6d648b7bcedd873a3c3fc117e3c..0d76f031c9accf06b538c2033d3ab2ed67ad87e8 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoSetValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/entityGenerator/base/elements/method/AssoSetValueGenerator.java @@ -1,37 +1,45 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.entityGenerator.base.elements.method; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.property.ClassPropertyGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.attr.ChildAttribute; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; -import com.inspur.edp.cef.gencommon.CefPropertyInfo; -import com.inspur.edp.cef.gencommon.ReflectionUtils; import com.inspur.edp.cef.generator.entityGenerator.base.DataTypeGeneratorContext; import com.inspur.edp.cef.generator.entityGenerator.base.elements.AssoPropertyGenerator; import com.inspur.edp.cef.generator.overall.GeneratorUtil; -import com.inspur.edp.udt.entity.ISimpleUdtData; import lombok.var; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.CastExpression; +import org.eclipse.jdt.core.dom.ExpressionStatement; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.dom.SwitchCase; +import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.Type; import java.util.ArrayList; @@ -240,23 +248,9 @@ public class AssoSetValueGenerator extends ClassMethodGenerator { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - - ThrowStatement throwStatement= GeneratorUtil.getThrowStatement(ast,"属性名不存在:",param1,true); - addImport(CefException.class.getTypeName()); -// ClassInstanceCreation classInstanceCreation =ast.newClassInstanceCreation(); -// -// classInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// -// -// InfixExpression infixExpression =ast.newInfixExpression(); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// StringLiteral stringLiteral= ast.newStringLiteral(); -// stringLiteral.setLiteralValue("属性名不存在:"); -// infixExpression.setLeftOperand(stringLiteral); -// infixExpression.setRightOperand(ast.newSimpleName(param1)); -// classInstanceCreation.arguments().add(infixExpression); -// -// throwStatement.setExpression(classInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, param1); switchStatement.statements().add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/overall/GeneratorUtil.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/overall/GeneratorUtil.java index a0459c8835078d09c7df19d1cd4a2a0fb23c3061..d9d4fed37e1c7ae4fd9ec2d98c61fd9540e7869c 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/overall/GeneratorUtil.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/overall/GeneratorUtil.java @@ -1,28 +1,26 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.overall; -import com.ctc.wstx.util.StringUtil; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.inspur.edp.caf.generator.BaseGenerator; -import com.inspur.edp.caf.generator.BaseGeneratorContext; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.AnnotationInfo; -import com.inspur.edp.caf.generator.baseInfo.AnnotationType; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.cef.api.attr.PropertyGetAtrribute; @@ -46,12 +44,10 @@ import java.lang.reflect.Parameter; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.Objects; import org.eclipse.jdt.core.dom.*; -import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; import org.springframework.util.StringUtils; public final class GeneratorUtil { @@ -303,6 +299,7 @@ public final class GeneratorUtil { GenUtils.buildTypeLiteral(ast, BefDateTimeSerializer.class.getName()))); } + @Deprecated public static ThrowStatement getThrowStatement( AST ast, String message, String paramName,boolean messageInLeft){ InfixExpression infixExpression=ast.newInfixExpression(); StringLiteral stringLiteral =ast.newStringLiteral(); @@ -326,6 +323,7 @@ public final class GeneratorUtil { return getThrowStatement(ast,infixExpression); } + @Deprecated public static ThrowStatement getThrowStatement(AST ast, String message,MethodInvocation methodInvocation,boolean messageInLeft){ InfixExpression infixExpression=ast.newInfixExpression(); StringLiteral stringLiteral =ast.newStringLiteral(); @@ -348,6 +346,7 @@ public final class GeneratorUtil { } + @Deprecated public static ThrowStatement getThrowStatement(AST ast,Expression expression){ ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); if (expression!=null && !StringUtils.isEmpty(expression)){ @@ -356,6 +355,7 @@ public final class GeneratorUtil { return setThrowStatement(classInstanceCreation,ast); } + @Deprecated private static ThrowStatement setThrowStatement(ClassInstanceCreation classInstanceCreation,AST ast){ ThrowStatement throwStatement = ast.newThrowStatement(); classInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(CefException.class).getType(ast)); @@ -364,16 +364,36 @@ public final class GeneratorUtil { return throwStatement; } + @Deprecated public static ThrowStatement getThrowStatementWithMessage(AST ast, String message){ return getThrowStatement(ast,getStringLiteral(ast,message)); } + @Deprecated public static ThrowStatement getThrowStatementWithParamName(AST ast, String paramName){ ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); classInstanceCreation.arguments().add(ast.newSimpleName(paramName)); return setThrowStatement(classInstanceCreation,ast); } - + public static ThrowStatement getThrowBefExStatement(AST ast, String exceptionParam, String errorCode, String... errorParams){ + ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); + classInstanceCreation.setType(new TypeInfo(BefGenerationException.class).getType(ast)); + classInstanceCreation.arguments().add(StringUtils.hasLength(exceptionParam)? + ast.newSimpleName(exceptionParam) : ast.newNullLiteral()); + + classInstanceCreation.arguments().add( + ast.newQualifiedName(ast.newSimpleName("BefGenerationErrorCodeConst"), ast.newSimpleName(errorCode)) +// ast.newQualifiedType(new TypeInfo(BefGenerationErrorCodeConst.class).getType(ast), ast.newSimpleName(errorCode)) + ); + if (errorParams != null) { + for (String errorParam : errorParams) { + classInstanceCreation.arguments().add(ast.newSimpleName(errorParam)); + } + } + ThrowStatement throwStatement = ast.newThrowStatement(); + throwStatement.setExpression(classInstanceCreation); + return throwStatement; + } } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/RepositoryGenUtil.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/RepositoryGenUtil.java index b22ada1ff9d1545a2f11fb3d87e989a46f03a4b9..b792aeddd419cbd3728f10758fb633a17989a8aa 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/RepositoryGenUtil.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/RepositoryGenUtil.java @@ -1,17 +1,17 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository; @@ -20,13 +20,25 @@ import com.inspur.edp.caf.generator.baseInfo.AnnotationInfo; import com.inspur.edp.caf.generator.baseInfo.AnnotationType; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.generator.coreGenerator.base.CefCoreGeneratorContext; import com.inspur.edp.cef.generator.exception.CefGenException; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import io.iec.edp.caf.commons.utils.SpringBeanUtils; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.BooleanLiteral; +import org.eclipse.jdt.core.dom.Expression; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.Modifier; +import org.eclipse.jdt.core.dom.Name; +import org.eclipse.jdt.core.dom.ParameterizedType; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.Type; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import java.util.ArrayList; import java.util.HashMap; @@ -153,6 +165,7 @@ public class RepositoryGenUtil { * @param messageExpression * @return */ + @Deprecated public static ThrowStatement createThrowRuntimeException(AST ast, Expression messageExpression) { ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,messageExpression); // SetExceptionCode setExceptionCode =new SetExceptionCode(); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/createinstance/NestedCreateInsGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/createinstance/NestedCreateInsGenerator.java index d639e48db644e64e417984973789d702effb45b9..c682b2cb693d0a15fd02bea33f1046c79d14cbda 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/createinstance/NestedCreateInsGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/createinstance/NestedCreateInsGenerator.java @@ -1,25 +1,26 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository.adaptor.method.createinstance; import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.generator.repository.adaptor.AdapterGenUtils; import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenContext; @@ -98,36 +99,12 @@ public class NestedCreateInsGenerator extends CreateInsGenerator return ifStatement; } - private Statement getReturnValueStatement(String entityTypeName,String valueName) - { -// try { -// return new ObjectMapper().readValue((String)valueName, String.class); -// } catch (IOException e) { -// throw new RuntimeException(e); -// } - + private Statement getReturnValueStatement(String entityTypeName,String valueName) { TryStatement tryStatement = ast.newTryStatement(); Block tryBlock = ast.newBlock(); -// MethodInvocation deserializeInvocation = ast.newMethodInvocation(); -// ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); -// classInstanceCreation.setType(new TypeInfo(ObjectMapper.class).getType(ast, dacContext.getReposContext().getCefContext().getRootCompileUnitGenCtx())); -// deserializeInvocation.setExpression(classInstanceCreation); -// deserializeInvocation.setName(ast.newSimpleName("readValue")); -// CastExpression castExpression = ast.newCastExpression(); -// castExpression.setExpression(ast.newSimpleName(varObjectName)); -// castExpression.setType(ast.newSimpleType(ast.newName("String"))); -// deserializeInvocation.arguments().add(castExpression); -// TypeLiteral typeLiteral = ast.newTypeLiteral(); -// typeLiteral.setType(ast.newSimpleType(ast.newName(entityTypeName))); -// deserializeInvocation.arguments().add(typeLiteral); -// ReturnStatement returnStatement =ast.newReturnStatement(); -// returnStatement.setExpression(deserializeInvocation); -// tryBlock.statements().add(returnStatement); -// tryStatement.setBody(tryBlock); addGetMapperStatement(tryBlock); - MethodInvocation methodInvocation=ast.newMethodInvocation(); methodInvocation.setExpression(ast.newSimpleName("mapper")); methodInvocation.setName(ast.newSimpleName("readValue")); @@ -153,14 +130,10 @@ public class NestedCreateInsGenerator extends CreateInsGenerator singleVariableDeclaration.setName(ast.newSimpleName("e")); catchClause.setException(singleVariableDeclaration); Block catchBodyBlock=ast.newBlock(); -// SetExceptionCode setExceptionCode =new SetExceptionCode(); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatementWithParamName(ast,"e"); - addImport(CefException.class.getTypeName()); -// ClassInstanceCreation rtExceptionInstanceCreation=ast.newClassInstanceCreation(); -// setExceptionCode.setClassInstanceCreation(rtExceptionInstanceCreation,ast,"","e"); -// rtExceptionInstanceCreation.setType(new com.inspur.edp.caf.generator.baseInfo.TypeInfo(RuntimeException.class).getType(ast)); -// rtExceptionInstanceCreation.arguments().add(ast.newSimpleName("e")); - //throwStatement.setExpression(rtExceptionInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, "e", BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0011); + catchBodyBlock.statements().add(throwStatement); catchClause.setBody(catchBodyBlock); tryStatement.catchClauses().add(catchClause); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/getvaluegen/GetValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/getvaluegen/GetValueGenerator.java index cb01a0d5091aa51f070c979456ac2f7a47f80487..0a48e5e008198b5228a2047d2a0994fdbfe2fdb9 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/getvaluegen/GetValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/getvaluegen/GetValueGenerator.java @@ -1,27 +1,28 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository.adaptor.method.getvaluegen; import com.inspur.edp.bef.bizentity.GspBizEntityElement; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.caf.generator.utils.ExpressionUtils; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.designtime.api.IGspCommonField; import com.inspur.edp.cef.designtime.api.element.GspElementDataType; @@ -38,7 +39,6 @@ import java.util.ArrayList; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CastExpression; -import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.ParenthesizedExpression; @@ -312,8 +312,11 @@ public class GetValueGenerator extends ClassMethodGenerator { SwitchCase defaultCase = ast.newSwitchCase(); defaultCase.setExpression(null); switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,null); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, + BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, ColNameParam); + // ClassInstanceCreation classInstanceCreation = ast.newClassInstanceCreation(); // // classInstanceCreation.setType( diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/readproperty/DataTypeReadPropertyGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/readproperty/DataTypeReadPropertyGenerator.java index f4f4973586f09465671e7f6042467c665d45a60e..8f8e576d970de9f76ab1dbe6f91217c812a1d8c0 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/readproperty/DataTypeReadPropertyGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/readproperty/DataTypeReadPropertyGenerator.java @@ -1,38 +1,28 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository.adaptor.method.readproperty; -//import Inspur.Gsp.Caf.Generator.BaseInfoItem.*; -//import Inspur.Gsp.Caf.Generator.ClassMethodGenerator.*; -//import Inspur.Gsp.Caf.Generator.Utils.*; -//import Inspur.Gsp.Cef.Api.Attribute.*; -//import Inspur.Gsp.Cef.Api.Repository.*; -//import Inspur.Gsp.Cef.Repository.*; -//import Inspur.Gsp.Cef.RTGenerator.Common.*; -//import Microsoft.CodeAnalysis.*; -//import Microsoft.CodeAnalysis.CSharp.*; -//import Microsoft.CodeAnalysis.CSharp.Syntax.*; - import com.inspur.edp.bef.bizentity.GspBusinessEntity; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.ParameterInfo; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.caf.generator.method.ClassMethodGenerator; import com.inspur.edp.cef.api.attr.AssoUdtAtrribute; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.api.repository.readerWriter.ICefReader; import com.inspur.edp.cef.designtime.api.IGspCommonDataType; import com.inspur.edp.cef.designtime.api.IGspCommonField; @@ -44,23 +34,18 @@ import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.generator.repository.RepositoryGenUtil; import com.inspur.edp.cef.generator.repository.adaptor.method.createpropertydefmethod.*; import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenContext; -import com.inspur.edp.cef.repository.assembler.AssociationInfo; -import com.inspur.edp.cef.repository.dbcolumninfo.DbColumnInfo; import com.inspur.edp.cef.repository.dbcolumninfo.DbColumnInfoCollection; import com.inspur.edp.cef.repository.readerwriter.CefMappingReader; import com.inspur.edp.cef.repository.repo.BaseRootRepository; import com.inspur.edp.cef.spi.entity.IAuthFieldValue; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.List; -import com.inspur.edp.das.commonmodel.IGspCommonElement; import com.inspur.edp.das.commonmodel.IGspCommonObject; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.udt.designtime.api.entity.ComplexDataTypeDef; import com.inspur.edp.udt.designtime.api.entity.dbInfo.ColumnMapType; import org.eclipse.jdt.core.dom.Block; -import org.eclipse.jdt.core.dom.InfixExpression; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.dom.Name; @@ -71,35 +56,12 @@ import org.eclipse.jdt.core.dom.SwitchCase; import org.eclipse.jdt.core.dom.SwitchStatement; import org.eclipse.jdt.core.dom.ThrowStatement; -// -// public abstract object readproperty(string propertyName, ICefReader reader) -// { -// switch(propertyName) -// { -// case "Code": -// return reader.getString("Code"); -// case "DeptID": -// return getTreeInfoAssValue(propertyName,reader); -// Dictionary mapping =new Dictionary(); -// mapping.Add("Code1","Code"); -// mapping.Add("Name1","Name"); -// mapping.Add("TreeInfo1","TreeInfo"); -// CefMappingReader reader =new CefMappingReader(mapping); -// treeInfoRepository. -// default: -// throw new Exception(); -// } -// } -// public class DataTypeReadPropertyGenerator extends ClassMethodGenerator { public DataTypeReadPropertyGenerator(DataTypeDacGenContext dacContext, IGspCommonDataType gspCommonDataType, String nodeCode, boolean isChild, DbColumnInfoCollection dbColumns) { this.dacContext = dacContext; this.gspCommonDataType = gspCommonDataType; this.nodeCode = nodeCode; this.isChild = isChild; -// this.mappingPropNames = mappingPropNames; -// this.dbColumns = dbColumns; -// this.associationInfo = associationInfo; } public static final String paramPropName = "propertyName"; @@ -107,9 +69,6 @@ public class DataTypeReadPropertyGenerator extends ClassMethodGenerator { private DataTypeDacGenContext dacContext; private String nodeCode; private boolean isChild; -// private java.util.HashMap mappingPropNames; -// private DbColumnInfoCollection dbColumns; -// private java.util.ArrayList associationInfo; private IGspCommonDataType gspCommonDataType; @Override @@ -248,15 +207,6 @@ public class DataTypeReadPropertyGenerator extends ClassMethodGenerator { return returnStatement; } -// private AssociationInfo getAssociationInfo(String propertyName) { -// for (AssociationInfo item : associationInfo) { -// if (propertyName.equals(item.getSourceColumn())) { -// return item; -// } -// } -// throw new RuntimeException("没有找到关联信息" + propertyName); -// } - private void buildAssocationRefColumnStatements(GspAssociation associationInfo, IGspCommonField gspCommonField, String propertyName, java.util.ArrayList statements, java.util.ArrayList appendedSections) { if(gspCommonField.getChildAssociations() !=null && gspCommonField.getChildAssociations().size() > 0){ GspAssociation gspAssociation = gspCommonField.getChildAssociations().get(0); @@ -371,12 +321,9 @@ public class DataTypeReadPropertyGenerator extends ClassMethodGenerator { SwitchCase caseStatement = ast.newSwitchCase(); caseStatement.setExpression(null); statements.add(caseStatement); - addImport(CefException.class.getTypeName()); - InfixExpression messageExpression = ast.newInfixExpression(); - messageExpression.setLeftOperand(RepositoryGenUtil.createStringLiteral(ast, "找不到属性名")); - messageExpression.setRightOperand(RepositoryGenUtil.createVariableLiteral(ast, paramPropName)); - messageExpression.setOperator(InfixExpression.Operator.PLUS); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,messageExpression); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, null, BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0001, paramPropName); statements.add(throwStatement); } diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/setentityvalue/NestedSetEntityValueGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/setentityvalue/NestedSetEntityValueGenerator.java index b4b2d06feb6374afaa20e2ef157b7dc80dc872bb..d9264974fbeb3ad4a9c541a8a6abe365cf707da8 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/setentityvalue/NestedSetEntityValueGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/adaptor/method/setentityvalue/NestedSetEntityValueGenerator.java @@ -1,24 +1,25 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository.adaptor.method.setentityvalue; import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.generator.repository.adaptor.AdapterGenUtils; import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenContext; @@ -28,11 +29,22 @@ import com.inspur.edp.cef.repository.assembler.nesteddatatype.NestedDataTypeAsse import com.inspur.edp.cef.repository.dbcolumninfo.DbColumnInfoCollection; import com.inspur.edp.cef.spi.jsonser.abstractcefchange.BefDateSerUtil; import com.inspur.edp.das.commonmodel.IGspCommonObject; -import org.eclipse.jdt.core.dom.*; +import org.eclipse.jdt.core.dom.Block; +import org.eclipse.jdt.core.dom.CatchClause; +import org.eclipse.jdt.core.dom.ClassInstanceCreation; +import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.InfixExpression; +import org.eclipse.jdt.core.dom.MethodInvocation; +import org.eclipse.jdt.core.dom.ReturnStatement; +import org.eclipse.jdt.core.dom.SingleVariableDeclaration; +import org.eclipse.jdt.core.dom.Statement; +import org.eclipse.jdt.core.dom.ThrowStatement; +import org.eclipse.jdt.core.dom.TryStatement; +import org.eclipse.jdt.core.dom.TypeLiteral; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import java.io.IOException; -import java.lang.reflect.Method; -import java.util.ArrayList; public class NestedSetEntityValueGenerator extends SetEntityValueGenerator { @@ -152,12 +164,9 @@ public class NestedSetEntityValueGenerator extends SetEntityValueGenerator singleVariableDeclaration.setName(ast.newSimpleName("e")); catchClause.setException(singleVariableDeclaration); Block catchBodyBlock=ast.newBlock(); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement= GeneratorUtil.getThrowStatementWithParamName(ast,"e"); -// ClassInstanceCreation rtExceptionInstanceCreation=ast.newClassInstanceCreation(); -// rtExceptionInstanceCreation.setType(new TypeInfo(RuntimeException.class).getType(ast)); -// rtExceptionInstanceCreation.arguments().add(ast.newSimpleName("e")); -// throwStatement.setExpression(rtExceptionInstanceCreation); + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement= GeneratorUtil.getThrowBefExStatement(ast, "e", BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0011); catchBodyBlock.statements().add(throwStatement); catchClause.setBody(catchBodyBlock); tryStatement.catchClauses().add(catchClause); diff --git a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/dac/method/GetEntityAdaptorGenerator.java b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/dac/method/GetEntityAdaptorGenerator.java index 063272d3a9fb3048d4d382f6c163e87fca797b53..c9694b72a8da777322ce090eacf509487205934a 100644 --- a/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/dac/method/GetEntityAdaptorGenerator.java +++ b/common-entity-generator/src/main/java/com/inspur/edp/cef/generator/repository/dac/method/GetEntityAdaptorGenerator.java @@ -1,31 +1,28 @@ /* - * Copyright © OpenAtom Foundation. + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.inspur.edp.cef.generator.repository.dac.method; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; -import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.api.repository.GspDbType; import com.inspur.edp.cef.api.repository.adaptor.IEntityAdaptor; -import com.inspur.edp.cef.generator.overall.GeneratorUtil; import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenContext; import com.inspur.edp.cef.generator.repository.dac.DataTypeDacGenerator; import com.inspur.edp.cef.generator.repository.dac.EntityDacGenContext; -import lombok.var; import org.eclipse.jdt.core.dom.*; import java.util.Map; @@ -151,25 +148,4 @@ public class GetEntityAdaptorGenerator extends GetAdaptorGenerator { BreakStatement breakStatement=ast.newBreakStatement(); switchStatement.statements().add(breakStatement); } - - - private void setSwitchDefaultCase(SwitchStatement switchStatement) - { - SwitchCase defaultCase =ast.newSwitchCase(); - defaultCase.setExpression(null); - switchStatement.statements().add(defaultCase); - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement=GeneratorUtil.getThrowStatementWithMessage(ast,"暂不支持数据库类型:"); - -// ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation(); -// classInstanceCreation.setType(ast.newSimpleType(ast.newName(RuntimeException.class.getName()))); -// classInstanceCreation.arguments().add(GeneratorUtil.getStringLiteral(ast,"暂不支持数据库类型:")); -// InfixExpression infixExpression=ast.newInfixExpression(); -// infixExpression.setLeftOperand(GeneratorUtil.getStringLiteral(ast,"暂不支持数据库类型:")); -// infixExpression.setOperator(InfixExpression.Operator.PLUS); -// infixExpression.setRightOperand(); - - //throwStatement.setExpression(classInstanceCreation); - switchStatement.statements().add(throwStatement); - } } diff --git a/common-entity-variable-generator/pom.xml b/common-entity-variable-generator/pom.xml index c60c8f4b993d9dced5e6c16cff9609db1aa364fe..4ec95124fc7433184292527f14c1d2f462bb4578 100644 --- a/common-entity-variable-generator/pom.xml +++ b/common-entity-variable-generator/pom.xml @@ -14,21 +14,6 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - diff --git a/i18nresources/business_entity_generator_exception.properties b/i18nresources/business_entity_generator_exception.properties new file mode 100644 index 0000000000000000000000000000000000000000..2025f68493ef1c74ffc63316da3c7fa5fe5a9ce2 --- /dev/null +++ b/i18nresources/business_entity_generator_exception.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +GSP_BEF_GENERATION_0001=\u5C5E\u6027\u540D\u4E0D\u5B58\u5728\uFF1A[{0}] +GSP_BEF_GENERATION_0002=\u4E0D\u5B58\u5728\u5B50\u8868:[{0}] +GSP_BEF_GENERATION_0003=\u627E\u4E0D\u5230\u8282\u70B9\uFF0C\u8282\u70B9\u7F16\u53F7:[{0}] +GSP_BEF_GENERATION_0004=\u7D22\u5F15\u6570\u7EC4\u4E2D\u4E0D\u5B58\u5728\u5F53\u524D\u503C:[{0}] +GSP_BEF_GENERATION_0005=UDT \u6570\u636E\u5E8F\u5217\u5316\u5931\u8D25 +GSP_BEF_GENERATION_0006=\u514B\u9686\u5931\u8D25 +GSP_BEF_GENERATION_0007=\u4E0D\u5B58\u5728\u5B50\u5BF9\u8C61:[{0}] +GSP_BEF_GENERATION_0008=\u52A8\u6001\u5C5E\u6027\u4E0D\u5141\u8BB8\u8D4B\u503C +GSP_BEF_GENERATION_0009=\u53D8\u66F4\u96C6\u7C7B\u578B\u4E0D\u6B63\u786E +GSP_BEF_GENERATION_0010=\u53EA\u8BFB\u5185\u5BB9\u4E0D\u80FD\u53D8\u66F4 +GSP_BEF_GENERATION_0011=\u6570\u636E\u53CD\u5E8F\u5217\u5316\u5931\u8D25 \ No newline at end of file diff --git a/i18nresources/en/business_entity_generator_exception.en.properties b/i18nresources/en/business_entity_generator_exception.en.properties new file mode 100644 index 0000000000000000000000000000000000000000..3e86cf79b14850c036105f2f00b90c90a94cb0b4 --- /dev/null +++ b/i18nresources/en/business_entity_generator_exception.en.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +GSP_BEF_GENERATION_0001=Property does not exist: [{0}] +GSP_BEF_GENERATION_0002=Subtable does not exist: [{0}] +GSP_BEF_GENERATION_0003=Node not found, Node ID: [{0}] +GSP_BEF_GENERATION_0004=Current value does not exist in the array index: [{0}] +GSP_BEF_GENERATION_0005=UDT data serialization failed +GSP_BEF_GENERATION_0006=Clone failed +GSP_BEF_GENERATION_0007=Child object does not exist: [{0}] +GSP_BEF_GENERATION_0008=Dynamic properties are not allowed for assignment. +GSP_BEF_GENERATION_0009=Change set type is incorrect. +GSP_BEF_GENERATION_0010=Read-only content cannot be modified. +GSP_BEF_GENERATION_0011=Data deserialization failed. \ No newline at end of file diff --git a/i18nresources/zh-CHT/business_entity_generator_exception.zh-CHT.properties b/i18nresources/zh-CHT/business_entity_generator_exception.zh-CHT.properties new file mode 100644 index 0000000000000000000000000000000000000000..71a1c00be5ca14d6ef4d76131e1b74f4b567e952 --- /dev/null +++ b/i18nresources/zh-CHT/business_entity_generator_exception.zh-CHT.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +GSP_BEF_GENERATION_0001=\u5C6C\u6027\u540D\u4E0D\u5B58\u5728\uFF1A[{0}] +GSP_BEF_GENERATION_0002=\u5B50\u8868\u4E0D\u5B58\u5728\uFF1A[{0}] +GSP_BEF_GENERATION_0003=\u627E\u4E0D\u5230\u7BC0\u9EDE\uFF0C\u7BC0\u9EDE\u7DE8\u865F\uFF1A[{0}] +GSP_BEF_GENERATION_0004=\u7576\u524D\u503C\u5728\u9663\u5217\u7D22\u5F15\u4E2D\u4E0D\u5B58\u5728\uFF1A[{0}] +GSP_BEF_GENERATION_0005=UDT \u8CC7\u6599\u5E8F\u5217\u5316\u5931\u6557 +GSP_BEF_GENERATION_0006=\u8907\u88FD\u5931\u6557 +GSP_BEF_GENERATION_0007=\u5B50\u7269\u4EF6\u4E0D\u5B58\u5728\uFF1A[{0}] +GSP_BEF_GENERATION_0008=\u52D5\u614B\u5C6C\u6027\u4E0D\u5141\u8A31\u8CE6\u503C +GSP_BEF_GENERATION_0009=\u8B8A\u66F4\u96C6\u985E\u578B\u4E0D\u6B63\u78BA\u3002 +GSP_BEF_GENERATION_0010=\u552F\u8B80\u5167\u5BB9\u7121\u6CD5\u4FEE\u6539 +GSP_BEF_GENERATION_0011=\u8CC7\u6599\u53CD\u5E8F\u5217\u5316\u5931\u6557 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7796afd1732f35fd37f4769d87458aa94d02b1b0..1a1421efe5f67a8052825d1d89cf5f04d76777f4 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + io.iec.edp + caf-boot-parent + 1.5.0 + + com.inspur.edp business-entity-generator1 0.1.1-SNAPSHOT @@ -30,6 +36,7 @@ common-entity-generator unified-datatype-generator common-entity-variable-generator + business-entity-generator-exception @@ -60,6 +67,11 @@ unified-datatype-generator ${project.version} + + com.inspur.edp + business-entity-generator-exception + ${project.version} + @@ -95,53 +107,12 @@ - - org.springframework - spring-beans - 5.1.8.RELEASE - - - com.fasterxml.jackson.core - jackson-core - 2.7.4 - - - com.fasterxml.jackson.core - jackson-databind - 2.7.4 - - - jakarta.ws.rs - jakarta.ws.rs-api - 2.1.5 - - - org.projectlombok - lombok - 1.18.2 - compile - org.eclipse.jdt core 3.3.0-v_771 compile - - io.iec.edp - caf-security-core - 1.0.0 - - - io.iec.edp - caf-boot-commons-utils - 0.2.7 - - - io.iec.edp - caf-boot-commons-autoconfigure - 0.2.9 - @@ -169,11 +140,11 @@ common-entity-model ${cef.version} - - com.inspur.edp - common-entity-framework-api - ${cef.version} - + + + + + com.inspur.edp common-entity-framework-spi diff --git a/unified-datatype-generator/pom.xml b/unified-datatype-generator/pom.xml index 9aa2463245bccd65ddfbd622e1f45107b2b699d6..4d4d67dd9a0e5b17d9548bd649b123c4e01447e9 100644 --- a/unified-datatype-generator/pom.xml +++ b/unified-datatype-generator/pom.xml @@ -15,20 +15,6 @@ ~ limitations under the License. --> - - diff --git a/unified-datatype-generator/src/main/java/com/inspur/edp/udt/generator/api/typeprocessers/persistencevaluereader/JsonSerializePersistenceValueReadGenerator.java b/unified-datatype-generator/src/main/java/com/inspur/edp/udt/generator/api/typeprocessers/persistencevaluereader/JsonSerializePersistenceValueReadGenerator.java index 9c74109eb69a03fb886c499ec1026b3b2d49d62d..2053933fd86612107c3c4a0ea2901046519e25b4 100644 --- a/unified-datatype-generator/src/main/java/com/inspur/edp/udt/generator/api/typeprocessers/persistencevaluereader/JsonSerializePersistenceValueReadGenerator.java +++ b/unified-datatype-generator/src/main/java/com/inspur/edp/udt/generator/api/typeprocessers/persistencevaluereader/JsonSerializePersistenceValueReadGenerator.java @@ -18,6 +18,8 @@ package com.inspur.edp.udt.generator.api.typeprocessers.persistencevaluereader; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.bef.generator.exception.BefGenerationErrorCodeConst; +import com.inspur.edp.bef.generator.exception.BefGenerationException; import com.inspur.edp.caf.generator.baseInfo.TypeInfo; import com.inspur.edp.cef.api.message.CefException; import com.inspur.edp.cef.generator.overall.GeneratorUtil; @@ -29,7 +31,6 @@ public class JsonSerializePersistenceValueReadGenerator extends UdtGetPersistenc public JsonSerializePersistenceValueReadGenerator() { } - //JsonConvert.SerializeObject(data) @Override protected Block buildMethodBody() { var returnStatement = ast.newReturnStatement(); @@ -66,15 +67,9 @@ public class JsonSerializePersistenceValueReadGenerator extends UdtGetPersistenc } private Block getException(){ - addImport(CefException.class.getTypeName()); - ThrowStatement throwStatement = GeneratorUtil.getThrowStatement(ast,"udt数据序列化失败","e",true); -// var creation = ast.newClassInstanceCreation(); -// creation.setType(ast.newSimpleType(ast.newSimpleName("RuntimeException"))); -// -// creation.arguments().add(ExpressionUtils.getStringLiteral(ast, "udt数据序列化失败")); -// creation.arguments().add(ast.newSimpleName("e")); -// throwStatement.setExpression(creation); - + addImport(BefGenerationException.class.getTypeName()); + addImport(BefGenerationErrorCodeConst.class.getTypeName()); + ThrowStatement throwStatement = GeneratorUtil.getThrowBefExStatement(ast, "e", BefGenerationErrorCodeConst.GSP_BEF_GENERATION_0005); var block = ast.newBlock(); block.statements().add(throwStatement); return block;