vue react jhipster

react - jhipster registry



¿Cómo eliminar una entidad después de crearla usando jhipster? (7)

He creado 3 entidades (Autor, Libro, Biblioteca) usando el comando "yo jhipster: entity" pero en una entidad (Biblioteca) tuve una relación ManyToMany (con el Libro) pero eso provocó que "mappedBy reference una propiedad de entidad objetivo desconocida: com. tst.testdomain.domain.Book.librarys in com.tst.testdomain.docmain.Library.books "entonces, ¿cuál es la forma limpia de eliminar la entidad de la Biblioteca? ¿Sería útil un comando como "yo jhipster: entitydelete"?


Debes eliminar lo siguiente:

rm -rf src/main/resources/config/liquibase/changelog/XXX_added_entity_YourEntity.xml rm -rf src/main/java/com/radsphere/jeces/domain/YourEntity.java rm -rf src/main/java/com/radsphere/jeces/repository/YourEntityRepository.java rm -rf src/main/java/com/radsphere/jeces/web/rest/YourEntityResource.java rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntitys.html rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity-detail.html rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity.js rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity.controller.js rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity-detail.controller.js rm -rf src/main/webapp/scripts/components/entities/YourEntity/YourEntity.service.js rm -rf src/test/java/com/radsphere/jeces/web/rest/YourEntityResourceTest.java rm -rf src/main/webapp/i18n/en/YourEntity.json rm -rf src/main/webapp/i18n/fr/YourEntity.json

Y elimine la referencia de config / liquibase / master.xml:

<?xml version="1.0" encoding="utf-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> <include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307175923_added_entity_Company.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307180142_added_entity_UserTypeRecruiter.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307180338_added_entity_UserTypeCandidate.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307180448_added_entity_QuestionType.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307180612_added_entity_Question.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307180849_added_entity_Answer.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307181033_added_entity_CandidateAnswer.xml" relativeToChangelogFile="false"/> <!--<include file="classpath:config/liquibase/changelog/20150307181249_added_entity_your_removed_entity.xml" relativeToChangelogFile="false"/>--> <include file="classpath:config/liquibase/changelog/20150307182736_added_entity_ExamTemplate.xml" relativeToChangelogFile="false"/> <include file="classpath:config/liquibase/changelog/20150307182950_added_entity_Exam.xml" relativeToChangelogFile="false"/> <!-- JHipster will add liquibase changelogs here -->



He hecho algunas adiciones a las respuestas de SparX y Meme.

  • Debe eliminar el archivo DTO generado para la entidad, si ha elegido "usar DTO''s" al generar su entidad,
  • JHipster usa Mapstruct para mapear Entity y DTO . Si usa DTO, entonces necesita eliminar las clases de asignador que JHipster generó para usted
  • Debe eliminar las referencias de archivo javascript de las entidades eliminadas de "webapp / index.html"
  • Debe eliminar las definiciones i18n de la entidad eliminada de "webapp / i18n / * / global.json"
  • Debe eliminar los enlaces de menú de "webapp / scripts / components / navbar.html"
  • Si desea actualizar la definición de la entidad de actualización y regenerar la entidad en el futuro, puede mantener ./.jhipster/${ENTITY_NAME}.json

Actualicé el script bash de SparX (delete-entity.sh) para preguntar si se debe eliminar el archivo de definición de entidad o no. Además, la sintaxis "$ {ENTITY_NAME ^}" (que se usa para convertir la primera letra del nombre de la entidad en mayúsculas) no se ejecuta en versiones anteriores de bash (como 3.2).

El script bash actualizado está abajo. Simplemente coloque este script en la carpeta donde se encuentra su pom.xml .

Ejemplo de caso de uso: si el ID de grupo de su proyecto "com.example" y si desea eliminar una entidad denominada como "ciudad" , a continuación se muestra un comando de ejemplo:

./delete-entity.sh com / example / city

#!/usr/bin/env bash echo; if [ -z "$1" ]; then printf "Required argument GROUP_ID is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME./n"; exit 1; else GROUP_ID=$1; echo "GROUP_ID is set to ''$1''."; fi if [ -z "$2" ]; then printf "Required argument ENTITY_NAME is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME ./n"; exit 1; else ENTITY_NAME=$2; JAVA_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr ''[a-z]'' ''[A-Z]''`${ENTITY_NAME:1} echo "ENTITY_NAME is set to ''$2''." echo "Java entity name inferred as: ''${JAVA_ENTITY_NAME}''."; fi JAVA_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr ''[a-z]'' ''[A-Z]''`${ENTITY_NAME:1} QUESTION=$''You may want to keep definition file(.jhipster/${JAVA_ENTITY_NAME}.json) in case you want to regenerate entity in the future./nDo you want to delete entity definition file also?'' while true; do read -p "${QUESTION}" yn case $yn in [Yy]* ) rm -rf ./.jhipster/${ENTITY_NAME}.json; break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done echo; echo "Starting to delete files..."; rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${JAVA_ENTITY_NAME}.xml rm -rf src/main/java/${GROUP_ID}domain/${JAVA_ENTITY_NAME}.java rm -rf src/main/java/${GROUP_ID}repository/${JAVA_ENTITY_NAME}Repository.java rm -rf src/main/java/${GROUP_ID}service/${JAVA_ENTITY_NAME}Service.java rm -rf src/main/java/${GROUP_ID}service/impl/${JAVA_ENTITY_NAME}ServiceImpl.java rm -rf src/main/java/${GROUP_ID}repository/search/${JAVA_ENTITY_NAME}SearchRepository.java rm -rf src/main/java/${GROUP_ID}web/rest/${JAVA_ENTITY_NAME}Resource.java rm -rf src/main/java/${GROUP_ID}web/rest/dto/${JAVA_ENTITY_NAME}DTO.java rm -rf src/main/java/${GROUP_ID}web/rest/mapper/${JAVA_ENTITY_NAME}Mapper.java rm -rf target/generated-sources/${GROUP_ID}web/rest/mapper/${JAVA_ENTITY_NAME}MapperImpl.java rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}s.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME} rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.service.js rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.search.service.js rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME} rm -rf src/test/java/${GROUP_ID}web/rest/${ENTITY_NAME}ResourceIntTest.java rm -rf src/test/gatling/simulations/${ENTITY_NAME}GatlingTest.scala rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.spec.js rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME} rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/fr/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json echo "Deleting entity ''${ENTITY_NAME}'' is completed."; echo; echo "-----------------------------------------------------"; echo "Do not forget to manually correct these files also: "; echo "-----------------------------------------------------"; echo " --> src/main/webapp/index.html" echo " --> src/main/webapp/scripts/compopnents/navbar.html" echo " --> src/main/webapp/i18n/**/global.json" echo " --> src/main/resources/config/liquibase/master.xml (if you use liquibase)" echo " --> src/main/resources/config/mongeez/master.xml (if you use mongodb)"


Tienes razón, un comando de eliminación sería útil. Pero este comando no existe hoy. Quizás se añadirá. Si quieres borrar entidad, debes hacerlo manualmente. Así que elimine todos los archivos generados para su entidad: dominio, repositorio, resto, prueba, controlador y servicios de Angularjs, vista HTML, enlace en el menú, vista HTML


Yo uso git scm para esto. No solo los archivos generados deben ser eliminados. jHipster también modifica los archivos, de modo que con los que necesita para mantener el archivo, pero anular el cambio.

Cada vez que creo una entidad hago una confirmación por separado para poder hacer un seguimiento de lo que hizo jHipster para cada entidad.

Para borrar todos los cambios desde el último commit que hago.

git reset --hard git clean -fd

Si he hecho eso, pero también necesito retroceder el compromiso anterior, lo hago.

git reset --hard HEAD~1

Los compromisos son locales con git, por lo tanto, no es hasta que se presionen estos compromisos que se compartirán.


es simple, solo necesita eliminar la entidad en el directorio .jhipster / entityName.json y eso es todo.

Puede ejecutar la "yo: entidad jhipster" de nuevo y anular todo lo demás.

Meme.-


EDITADO : script agregado para la versión más reciente de jhipster 3.9.0

Mi script delete-entity.sh para la versión 2.26.2 de jhipster , basado en la respuesta de @shacharsol.

Uso: ./delete-entity GROUP_ID ENTITY_NAME

GROUP_ID: com / subpackage / and / so / on / (termina con ''/'')

ENTITY_NAME: firstLowercaseNameOfEntity

Ejemplo: ./delete-entity uz / javlon / transInfo

#!/usr/bin/env bash echo "################"; if [ -z "$1" ]; then printf "Required argument GROUP_ID is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME./n"; exit 1; else GROUP_ID=$1; echo "GROUP_ID is set to ''$1''."; fi if [ -z "$2" ]; then printf "Required argument ENTITY_NAME is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME ./n"; exit 1; else ENTITY_NAME=$2; echo "ENTITY_NAME is set to ''$2''."; fi echo; rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${ENTITY_NAME^}.xml rm -rf src/main/java/${GROUP_ID}domain/${ENTITY_NAME^}.java rm -rf src/main/java/${GROUP_ID}repository/${ENTITY_NAME^}Repository.java rm -rf src/main/java/${GROUP_ID}repository/search/${ENTITY_NAME^}SearchRepository.java rm -rf src/main/java/${GROUP_ID}web/rest/${ENTITY_NAME^}Resource.java rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}s.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.html rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.controller.js rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME} rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.service.js rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.search.service.js rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME} rm -rf src/test/java/${GROUP_ID}web/rest/${ENTITY_NAME^}ResourceIntTest.java rm -rf src/test/gatling/simulations/${ENTITY_NAME^}GatlingTest.scala rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.spec.js rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME} rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json rm -rf ./.jhipster/${ENTITY_NAME^}.json echo; echo "Deleting ${ENTITY_NAME^} is completed."; echo "################";

Mi otro script delete-entity.sh para la versión 3.9.0 de jhipster , basado en la respuesta de @Tevfik Kiziloren.

#!/usr/bin/env bash echo; if [ -z "$1" ]; then printf "Required argument GROUP_ID is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME./n"; exit 1; else GROUP_ID=$1; echo "GROUP_ID is set to ''$1''."; fi if [ -z "$2" ]; then printf "Required argument ENTITY_NAME is not set. /nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME ./n"; exit 1; else ENTITY_NAME=$2; JAVA_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr ''[a-z]'' ''[A-Z]''`${ENTITY_NAME:1} echo "ENTITY_NAME is set to ''$2''." echo "Java entity name inferred as: ''${JAVA_ENTITY_NAME}''."; fi JAVA_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr ''[a-z]'' ''[A-Z]''`${ENTITY_NAME:1} UNDERSCORED_FOLDER_NAME=`echo ${ENTITY_NAME} | sed -r ''s/([a-z0-9])([A-Z])//1-/L/2/g''` echo ${UNDERSCORED_FOLDER_NAME}; QUESTION=$''You may want to keep definition file(.jhipster/''${JAVA_ENTITY_NAME}''.json) in case you want to regenerate entity in the future./nDo you want to delete entity definition file also?'' while true; do read -p "${QUESTION}" yn case $yn in [Yy]* ) rm -rf ./.jhipster/${ENTITY_NAME}.json; break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done echo; echo "Starting to delete files..."; rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${JAVA_ENTITY_NAME}.xml rm -rf src/main/java/${GROUP_ID}domain/${JAVA_ENTITY_NAME}.java rm -rf src/main/java/${GROUP_ID}repository/${JAVA_ENTITY_NAME}Repository.java rm -rf src/main/java/${GROUP_ID}service/${JAVA_ENTITY_NAME}Service.java rm -rf src/main/java/${GROUP_ID}service/impl/${JAVA_ENTITY_NAME}ServiceImpl.java rm -rf src/main/java/${GROUP_ID}repository/search/${JAVA_ENTITY_NAME}SearchRepository.java rm -rf src/main/java/${GROUP_ID}web/rest/${JAVA_ENTITY_NAME}Resource.java rm -rf src/main/java/${GROUP_ID}web/rest/dto/${JAVA_ENTITY_NAME}DTO.java rm -rf src/main/java/${GROUP_ID}web/rest/mapper/${JAVA_ENTITY_NAME}Mapper.java rm -rf target/generated-sources/${GROUP_ID}web/rest/mapper/${JAVA_ENTITY_NAME}MapperImpl.java rm -rf src/main/webapp/app/entities/${UNDERSCORED_FOLDER_NAME}/* rm -rf src/test/java/${GROUP_ID}web/rest/${JAVA_ENTITY_NAME}ResourceIntTest.java rm -rf src/test/gatling/simulations/${JAVA_ENTITY_NAME}GatlingTest.scala rm -rf src/test/javascript/spec/app/entities/${UNDERSCORED_FOLDER_NAME}/* rm -rf src/test/javascript/spec/app/entities/${UNDERSCORED_FOLDER_NAME} rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/fr/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json echo "Deleting entity ''${ENTITY_NAME}'' is completed."; echo; echo "-----------------------------------------------------"; echo "Do not forget to manually correct these files also: "; echo "-----------------------------------------------------"; echo " --> src/main/webapp/index.html" echo " --> src/main/webapp/scripts/compopnents/navbar.html" echo " --> src/main/webapp/i18n/**/global.json" echo " --> src/main/resources/config/liquibase/master.xml (if you use liquibase)" echo " --> src/main/resources/config/mongeez/master.xml (if you use mongodb)"