CRJAZ0447I SQL statement execution when creating Team Area
Hello
When I try to create a Team Area associated to a Project Area that I create previously with the same code, is giving me the following error
com.ibm.team.repository.common.InternalRepositoryException: CRJAZ0447I SQL statement execution failed.Integrity constraint violation
SQL: INSERT INTO PROCESS.PROCESS_AREA (STATE_ID, ITEM_ID, CONTEXT_ID, MODIFIED, MODIFIED_BY_ITEM_ID, ARCHIVED, NAME, UNIQUE_NAME, PROJECT_AREA_ITEM_ID, PROJECT_AREA_PROCSS_DFNTN_TM_D, PROJECT_AREA_IS_INITIALIZED, PROJECT_AREA_INTERNAL_PUBLIC, PROJECT_AREA_RED_CCSS_LST_TM_D, PRJCT_R_NTRNLPRJCTDVLPMNTLNTMD, PROJECT_AREA_OWNING_APPLICTN_K, PRJCT_R_NTRNL_PRCSS_PRVDR_TM_D, PROJECT_AR_NTRNL_S_PRCSS_PRVDR, JZ_DISCRIMINATOR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 7)
SQL Exception #1
SQL Message: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'PROCESS_AREA_PK6' defined on 'PROCESS_AREA'.
SQL State: 23505
Error Code: 20000
Class: com.ibm.team.repository.service.internal.dataaccess.write2.Row
Item Handle: com.ibm.team.process.internal.common.impl.ProjectAreaImpl@314c314c (stateId: , itemId: , origin: <unset>, immutable: true) (contextId: , modified: 2011-08-22 13:25:38.804, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: null) (descSummary: PA example project based on the Scrum project template, archived: false, name: PA - 1314012315370, uniqueName: PA - 1314012315370(JTS-Sentinel-Id)) (isInitialized: false, internalPublic: false, internalVisibleToMembers: true, internalVisibleToAccessList: false, owningApplicationKey: JTS-Sentinel-Id, internalIsProcessProvider: false)
The code used to do that is the following:
IProcessDefinitionHandle processDefinitionHandle = processServerService. findProcessDefinition(SCRUM_PROCESS, null, null);
IProcessDefinition processDefinition = (IProcessDefinition) processDefinitionHandle.getFullState();
// create Project Area
IProjectArea area = (IProjectArea) IProjectArea.ITEM_TYPE.createItem();
String actualProjectName = projectName + " - "
+ System.currentTimeMillis();
area.setName(actualProjectName);
area.setProcessDefinition(processDefinition);
IDescription description = area.getDescription();
description.setSummary(projectName + " example project based on the Scrum project template");
IItemsResponse itemResponse = processServerService
.saveProcessItemWithOverride(area, false);
// create Team Area
ITeamArea teamArea = (ITeamArea) ITeamArea.ITEM_TYPE.createItem();
String actualTeamName = teamName + System.currentTimeMillis();
teamArea.setName(actualTeamName);
teamArea.addMember(getContributor());
area = (IProjectArea) area.getWorkingCopy();
teamArea.setProjectArea(area.getProjectArea());
area.getTeamAreaHierarchy().addRoot(teamArea,
area.getDevelopmentLines());
itemResponse = processServerService
.saveProcessItemsWithOverride(new IProcessItem[] { area, teamArea }, true);
itemResponse = processServerService.initializeProjectArea(area, null);
Can any giveme a clue about that?
Thanks
Amaury
When I try to create a Team Area associated to a Project Area that I create previously with the same code, is giving me the following error
com.ibm.team.repository.common.InternalRepositoryException: CRJAZ0447I SQL statement execution failed.Integrity constraint violation
SQL: INSERT INTO PROCESS.PROCESS_AREA (STATE_ID, ITEM_ID, CONTEXT_ID, MODIFIED, MODIFIED_BY_ITEM_ID, ARCHIVED, NAME, UNIQUE_NAME, PROJECT_AREA_ITEM_ID, PROJECT_AREA_PROCSS_DFNTN_TM_D, PROJECT_AREA_IS_INITIALIZED, PROJECT_AREA_INTERNAL_PUBLIC, PROJECT_AREA_RED_CCSS_LST_TM_D, PRJCT_R_NTRNLPRJCTDVLPMNTLNTMD, PROJECT_AREA_OWNING_APPLICTN_K, PRJCT_R_NTRNL_PRCSS_PRVDR_TM_D, PROJECT_AR_NTRNL_S_PRCSS_PRVDR, JZ_DISCRIMINATOR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 7)
SQL Exception #1
SQL Message: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'PROCESS_AREA_PK6' defined on 'PROCESS_AREA'.
SQL State: 23505
Error Code: 20000
Class: com.ibm.team.repository.service.internal.dataaccess.write2.Row
Item Handle: com.ibm.team.process.internal.common.impl.ProjectAreaImpl@314c314c (stateId: , itemId: , origin: <unset>, immutable: true) (contextId: , modified: 2011-08-22 13:25:38.804, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: null) (descSummary: PA example project based on the Scrum project template, archived: false, name: PA - 1314012315370, uniqueName: PA - 1314012315370(JTS-Sentinel-Id)) (isInitialized: false, internalPublic: false, internalVisibleToMembers: true, internalVisibleToAccessList: false, owningApplicationKey: JTS-Sentinel-Id, internalIsProcessProvider: false)
The code used to do that is the following:
IProcessDefinitionHandle processDefinitionHandle = processServerService. findProcessDefinition(SCRUM_PROCESS, null, null);
IProcessDefinition processDefinition = (IProcessDefinition) processDefinitionHandle.getFullState();
// create Project Area
IProjectArea area = (IProjectArea) IProjectArea.ITEM_TYPE.createItem();
String actualProjectName = projectName + " - "
+ System.currentTimeMillis();
area.setName(actualProjectName);
area.setProcessDefinition(processDefinition);
IDescription description = area.getDescription();
description.setSummary(projectName + " example project based on the Scrum project template");
IItemsResponse itemResponse = processServerService
.saveProcessItemWithOverride(area, false);
// create Team Area
ITeamArea teamArea = (ITeamArea) ITeamArea.ITEM_TYPE.createItem();
String actualTeamName = teamName + System.currentTimeMillis();
teamArea.setName(actualTeamName);
teamArea.addMember(getContributor());
area = (IProjectArea) area.getWorkingCopy();
teamArea.setProjectArea(area.getProjectArea());
area.getTeamAreaHierarchy().addRoot(teamArea,
area.getDevelopmentLines());
itemResponse = processServerService
.saveProcessItemsWithOverride(new IProcessItem[] { area, teamArea }, true);
itemResponse = processServerService.initializeProjectArea(area, null);
Can any giveme a clue about that?
Thanks
Amaury
2 answers
Hello
When I try to create a Team Area associated to a Project Area that I create previously with the same code, is giving me the following error
com.ibm.team.repository.common.InternalRepositoryException: CRJAZ0447I SQL statement execution failed.Integrity constraint violation
SQL: INSERT INTO PROCESS.PROCESS_AREA (STATE_ID, ITEM_ID, CONTEXT_ID, MODIFIED, MODIFIED_BY_ITEM_ID, ARCHIVED, NAME, UNIQUE_NAME, PROJECT_AREA_ITEM_ID, PROJECT_AREA_PROCSS_DFNTN_TM_D, PROJECT_AREA_IS_INITIALIZED, PROJECT_AREA_INTERNAL_PUBLIC, PROJECT_AREA_RED_CCSS_LST_TM_D, PRJCT_R_NTRNLPRJCTDVLPMNTLNTMD, PROJECT_AREA_OWNING_APPLICTN_K, PRJCT_R_NTRNL_PRCSS_PRVDR_TM_D, PROJECT_AR_NTRNL_S_PRCSS_PRVDR, JZ_DISCRIMINATOR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 7)
SQL Exception #1
SQL Message: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'PROCESS_AREA_PK6' defined on 'PROCESS_AREA'.
SQL State: 23505
Error Code: 20000
Class: com.ibm.team.repository.service.internal.dataaccess.write2.Row
Item Handle: com.ibm.team.process.internal.common.impl.ProjectAreaImpl@314c314c (stateId: , itemId: , origin: <unset>, immutable: true) (contextId: , modified: 2011-08-22 13:25:38.804, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: null) (descSummary: PA example project based on the Scrum project template, archived: false, name: PA - 1314012315370, uniqueName: PA - 1314012315370(JTS-Sentinel-Id)) (isInitialized: false, internalPublic: false, internalVisibleToMembers: true, internalVisibleToAccessList: false, owningApplicationKey: JTS-Sentinel-Id, internalIsProcessProvider: false)
The code used to do that is the following:
IProcessDefinitionHandle processDefinitionHandle = processServerService. findProcessDefinition(SCRUM_PROCESS, null, null);
IProcessDefinition processDefinition = (IProcessDefinition) processDefinitionHandle.getFullState();
// create Project Area
IProjectArea area = (IProjectArea) IProjectArea.ITEM_TYPE.createItem();
String actualProjectName = projectName + " - "
+ System.currentTimeMillis();
area.setName(actualProjectName);
area.setProcessDefinition(processDefinition);
IDescription description = area.getDescription();
description.setSummary(projectName + " example project based on the Scrum project template");
IItemsResponse itemResponse = processServerService
.saveProcessItemWithOverride(area, false);
// create Team Area
ITeamArea teamArea = (ITeamArea) ITeamArea.ITEM_TYPE.createItem();
String actualTeamName = teamName + System.currentTimeMillis();
teamArea.setName(actualTeamName);
teamArea.addMember(getContributor());
area = (IProjectArea) area.getWorkingCopy();
teamArea.setProjectArea(area.getProjectArea());
area.getTeamAreaHierarchy().addRoot(teamArea,
area.getDevelopmentLines());
itemResponse = processServerService
.saveProcessItemsWithOverride(new IProcessItem[] { area, teamArea }, true);
itemResponse = processServerService.initializeProjectArea(area, null);
Can any giveme a clue about that?
Thanks
Amaury
Hi,
When you first saved the Project area using
IItemsResponse itemResponse = processServerService
.saveProcessItemWithOverride(area, false);
You should first get the saved project area area = (IProjectArea)itemResponse.getFirstItem(); before you use it to add team area to it
hola, yo tenía el mismo problema. Lo que hice fue:
1. Crear el TimeLine.
2. Buscar el TimeLineCreado y settearlo en la nueva Iteración.
3. Crear la iteración.
/**
* Crear una linea de tiempo (plan).
*
* Fecha inicio TimeLine.
* Fecha fin TimeLine.
* Nombre de TimeLine.
*/
public void crearTimeLines(Date fechaInicio, Date fechaFin, String nombre) {
try {
IProcessItemService service = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
IProjectArea projectAreaCopy = (IProjectArea) PROJECT_AREA.getWorkingCopy();
IDevelopmentLine developmentLine = (IDevelopmentLine) IDevelopmentLine.ITEM_TYPE.createItem();
developmentLine.setId(nombre);
developmentLine.setName(nombre);
developmentLine.setProjectArea(projectAreaCopy);
developmentLine.setStartDate(fechaInicio);
developmentLine.setEndDate(fechaFin);
projectAreaCopy.addDevelopmentLine(developmentLine);
IProcessItem[] items = service.save(new IProcessItem[] { projectAreaCopy, developmentLine }, MONITOR);
MONITOR.subTask("[" + developmentLine.getId() + "] creado");
crearIteracion(developmentLine.getId(), "Iteracion1");
crearIteracion(developmentLine.getId(), "Iteracion1");
crearIteracion(developmentLine.getId(), "Iteracion1");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Permite crear una iteración y asignarla a una línea de tiempo (plan).
*
* Id de la línea de tiempo a la cual se le va a asignar la iteración.
* Nombre de la iteración.
*/
public void crearIteracion(String idTimeLine, String nombreIteracion) {
try {
IAuditableClient fAuditableClient = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
IDevelopmentLineHandle[] devLines = PROJECT_AREA.getDevelopmentLines();
IDevelopmentLine developmentLine = null;
for (IDevelopmentLineHandle developmentLineHandle : devLines) {
developmentLine = fAuditableClient.resolveAuditable(developmentLineHandle, ItemProfile.DEVELOPMENT_LINE_DEFAULT, MONITOR);
if (idTimeLine.equals(developmentLine.getId()))
break;
}
IProcessItemService service = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
IIteration newIteration = (IIteration) IIteration.ITEM_TYPE.createItem();
newIteration.setName(nombreIteracion);
newIteration.setId(nombreIteracion + new Date());
IDevelopmentLine workingDevLine = (IDevelopmentLine) developmentLine.getWorkingCopy();
workingDevLine.addIteration((IIterationHandle) newIteration.getItemHandle());
newIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[] { workingDevLine, newIteration }, MONITOR);
MONITOR.subTask("[" + newIteration.getId() + "] creado");
} catch (Exception e) {
e.printStackTrace();
}
}