public void remove(Key requirementVersionKey) { LogEntityManager logEntityManager = new LogEntityManager(); Transaction txn = datastore.beginTransaction(); try { Entity artifactVersion = this.find(requirementVersionKey); Entity artifact = this.find(artifactVersion.getParent()); Entity project = this.find(artifact.getParent()); logEntityManager.persist( project.getKey(), new Date(), "O usu�rio " + artifact.getProperty(Artifact.CREATOR_ID) + " removeu o requisito " + artifact.getProperty(Artifact.NUMBER) + ": " + artifact.getProperty(Artifact.TITLE) + " do projeto " + project.getProperty(Project.PROJECT_NAME)); super.remove(requirementVersionKey); txn.commit(); } finally { if (txn.isActive()) { txn.rollback(); throw new TransactionException(); } } }
public Key persistRequirementOfExistingArtifact( Key artifactKey, String editorId, String editorEmail, String editedTitle, Text text) { ArtifactVersionEntityManager artifactVersionEntityManager = new ArtifactVersionEntityManager(); Map<String, Object> requirementVersionProperties = new HashMap<String, Object>(); requirementVersionProperties.put(RequirementVersion.TEXT, text); LogEntityManager logEntityManager = new LogEntityManager(); Key key; Transaction txn = datastore.beginTransaction(); try { Entity artifact = this.find(artifactKey); Entity project = this.find(artifact.getParent()); logEntityManager.persist( project.getKey(), new Date(), "Usu�rio " + artifact.getProperty(Artifact.CREATOR_ID) + " alterou o requisito " + artifact.getProperty(Artifact.NUMBER) + ": " + editedTitle + " ao projeto " + project.getProperty(Project.PROJECT_NAME)); Key artifactVersionKey = artifactVersionEntityManager.persistVersionOfExistingArtifact( artifactKey, editorId, editorEmail, ArtifactOperation.EDIT, editedTitle, new Date()); key = super.persist( RequirementVersion.ENTITY_NAME, requirementVersionProperties, artifactVersionKey); txn.commit(); return key; } finally { if (txn.isActive()) { txn.rollback(); throw new TransactionException(); } } }
public Key persistRequirementOfNewArtifact( Key projectKey, String editorId, String editorEmail, String artifactTitle, Text text) { ArtifactVersionEntityManager artifactVersionEntityManager = new ArtifactVersionEntityManager(); Map<String, Object> requirementVersionProperties = new HashMap<String, Object>(); requirementVersionProperties.put(RequirementVersion.TEXT, text); LogEntityManager logEntityManager = new LogEntityManager(); Key key; Transaction txn = datastore.beginTransaction(); try { Entity project = this.find(projectKey); int number = this.getLatestRequirementVersionsByProject(projectKey).size() + 1; Key artifactVersionKey = artifactVersionEntityManager.persistVersionOfNewArtifact( projectKey, editorId, editorEmail, artifactTitle, new Date(), number); key = super.persist( RequirementVersion.ENTITY_NAME, requirementVersionProperties, artifactVersionKey); logEntityManager.persist( project.getKey(), new Date(), "Usu�rio " + editorEmail + " adicionou o requisito " + number + ": " + artifactTitle + " ao projeto " + project.getProperty(Project.PROJECT_NAME)); txn.commit(); return key; } finally { if (txn.isActive()) { txn.rollback(); throw new TransactionException(); } } }