Program: 35665
Project: 35665
Buggy source:
@Override public Object create(User user,PropertyMap properties){
  projectModel=(ProjectModelDTO)properties.get(AdminUtil.ADMIN_PROJECT_MODEL);
  if (projectModel != null && ProjectModelStatus.DRAFT.equals(projectModel.getStatus())) {
    if (projectModel.getId() != -1) {
      update(user,projectModel,properties);
      if (modelToUpdate != null) {
        ProjectModelDTO projectDTOUpdated=mapper.map(modelToUpdate,ProjectModelDTO.class);
        return projectDTOUpdated;
      }
    }
 else {
      ProjectModel pM=new ProjectModel();
      String pMName=(String)properties.get(AdminUtil.PROP_PM_NAME);
      ProjectModelType pMUse=(ProjectModelType)properties.get(AdminUtil.PROP_PM_USE);
      pM.setName(pMName);
      pM.setStatus(ProjectModelStatus.DRAFT);
      List<ProjectModelVisibility> visibilities=new ArrayList<ProjectModelVisibility>();
      ProjectModelVisibility v=new ProjectModelVisibility();
      v.setModel(pM);
      v.setType(pMUse);
      v.setOrganization(user.getOrganization());
      visibilities.add(v);
      pM.setVisibilities(visibilities);
      ProjectDetails pMDetails=new ProjectDetails();
      Layout pMDetailsLayout=new Layout();
      pMDetailsLayout.setColumnsCount(1);
      pMDetailsLayout.setRowsCount(4);
      pMDetails.setLayout(pMDetailsLayout);
      pMDetails.setProjectModel(pM);
      LayoutGroup detailsGroup=new LayoutGroup();
      detailsGroup.setTitle("String_Node_Str");
      detailsGroup.setColumn(0);
      detailsGroup.setRow(0);
      detailsGroup.setParentLayout(pMDetailsLayout);
      int order=0;
      for (      DefaultFlexibleElementType e : DefaultFlexibleElementType.values()) {
        DefaultFlexibleElement defaultElement=new DefaultFlexibleElement();
        defaultElement.setType(e);
        defaultElement.setValidates(false);
        defaultElement.setAmendable(false);
        em.persist(defaultElement);
        LayoutConstraint defaultLayoutConstraint=new LayoutConstraint();
        defaultLayoutConstraint.setParentLayoutGroup(detailsGroup);
        defaultLayoutConstraint.setElement(defaultElement);
        defaultLayoutConstraint.setSortOrder(order++);
        detailsGroup.addConstraint(defaultLayoutConstraint);
      }
      List<LayoutGroup> detailsGroups=new ArrayList<LayoutGroup>();
      detailsGroups.add(detailsGroup);
      pMDetailsLayout.setGroups(detailsGroups);
      ProjectBanner pMBanner=new ProjectBanner();
      Layout pMBannerLayout=new Layout();
      pMBannerLayout.setColumnsCount(3);
      pMBannerLayout.setRowsCount(2);
      pMBanner.setLayout(pMBannerLayout);
      pMBanner.setProjectModel(pM);
      List<LayoutGroup> bannerGroups=new ArrayList<LayoutGroup>();
      for (int i=0; i < 3; i++) {
        for (int j=0; j < 2; j++) {
          LayoutGroup bannerGroup=new LayoutGroup();
          bannerGroup.setColumn(i);
          bannerGroup.setRow(j);
          bannerGroup.setParentLayout(pMBannerLayout);
          bannerGroups.add(bannerGroup);
        }
      }
      pMBannerLayout.setGroups(bannerGroups);
      pM.setProjectDetails(pMDetails);
      pM.setProjectBanner(pMBanner);
      em.persist(pM);
      PhaseModel defaultRootPhase=new PhaseModel();
      defaultRootPhase.setName("String_Node_Str");
      defaultRootPhase.setParentProjectModel(pM);
      defaultRootPhase.setDisplayOrder(0);
      Layout phaseLayout=new Layout();
      phaseLayout.setColumnsCount(1);
      phaseLayout.setRowsCount(4);
      LayoutGroup phaseGroup=new LayoutGroup();
      phaseGroup.setTitle("String_Node_Str");
      phaseGroup.setColumn(0);
      phaseGroup.setRow(0);
      phaseGroup.setParentLayout(phaseLayout);
      List<LayoutGroup> phaseGroups=new ArrayList<LayoutGroup>();
      phaseGroups.add(phaseGroup);
      phaseLayout.setGroups(phaseGroups);
      defaultRootPhase.setLayout(phaseLayout);
      em.persist(defaultRootPhase);
      LogFrameModel defaultLogFrame=createLogFrame(pM);
      pM.setRootPhase(defaultRootPhase);
      pM.setLogFrameModel(defaultLogFrame);
      pM=em.merge(pM);
      return mapper.map(pM,ProjectModelDTO.class);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object create(User user,PropertyMap properties){
  projectModel=(ProjectModelDTO)properties.get(AdminUtil.ADMIN_PROJECT_MODEL);
  if (projectModel != null && ProjectModelStatus.DRAFT.equals(projectModel.getStatus())) {
    if (projectModel.getId() != -1) {
      update(user,projectModel,properties);
      if (modelToUpdate != null) {
        ProjectModelDTO projectDTOUpdated=mapper.map(modelToUpdate,ProjectModelDTO.class);
        return projectDTOUpdated;
      }
    }
 else {
      ProjectModel pM=new ProjectModel();
      String pMName=(String)properties.get(AdminUtil.PROP_PM_NAME);
      ProjectModelType pMUse=(ProjectModelType)properties.get(AdminUtil.PROP_PM_USE);
      pM.setName(pMName);
      pM.setStatus(ProjectModelStatus.DRAFT);
      List<ProjectModelVisibility> visibilities=new ArrayList<ProjectModelVisibility>();
      ProjectModelVisibility v=new ProjectModelVisibility();
      v.setModel(pM);
      v.setType(pMUse);
      v.setOrganization(user.getOrganization());
      visibilities.add(v);
      pM.setVisibilities(visibilities);
      ProjectDetails pMDetails=new ProjectDetails();
      Layout pMDetailsLayout=new Layout();
      pMDetailsLayout.setColumnsCount(1);
      pMDetailsLayout.setRowsCount(1);
      pMDetails.setLayout(pMDetailsLayout);
      pMDetails.setProjectModel(pM);
      LayoutGroup detailsGroup=new LayoutGroup();
      detailsGroup.setTitle("String_Node_Str");
      detailsGroup.setColumn(0);
      detailsGroup.setRow(0);
      detailsGroup.setParentLayout(pMDetailsLayout);
      int order=0;
      for (      DefaultFlexibleElementType e : DefaultFlexibleElementType.values()) {
        DefaultFlexibleElement defaultElement=new DefaultFlexibleElement();
        defaultElement.setType(e);
        defaultElement.setValidates(false);
        defaultElement.setAmendable(false);
        em.persist(defaultElement);
        LayoutConstraint defaultLayoutConstraint=new LayoutConstraint();
        defaultLayoutConstraint.setParentLayoutGroup(detailsGroup);
        defaultLayoutConstraint.setElement(defaultElement);
        defaultLayoutConstraint.setSortOrder(order++);
        detailsGroup.addConstraint(defaultLayoutConstraint);
      }
      List<LayoutGroup> detailsGroups=new ArrayList<LayoutGroup>();
      detailsGroups.add(detailsGroup);
      pMDetailsLayout.setGroups(detailsGroups);
      ProjectBanner pMBanner=new ProjectBanner();
      Layout pMBannerLayout=new Layout();
      pMBannerLayout.setColumnsCount(3);
      pMBannerLayout.setRowsCount(2);
      pMBanner.setLayout(pMBannerLayout);
      pMBanner.setProjectModel(pM);
      List<LayoutGroup> bannerGroups=new ArrayList<LayoutGroup>();
      for (int i=0; i < 3; i++) {
        for (int j=0; j < 2; j++) {
          LayoutGroup bannerGroup=new LayoutGroup();
          bannerGroup.setColumn(i);
          bannerGroup.setRow(j);
          bannerGroup.setParentLayout(pMBannerLayout);
          bannerGroups.add(bannerGroup);
        }
      }
      pMBannerLayout.setGroups(bannerGroups);
      pM.setProjectDetails(pMDetails);
      pM.setProjectBanner(pMBanner);
      em.persist(pM);
      PhaseModel defaultRootPhase=new PhaseModel();
      defaultRootPhase.setName("String_Node_Str");
      defaultRootPhase.setParentProjectModel(pM);
      defaultRootPhase.setDisplayOrder(0);
      Layout phaseLayout=new Layout();
      phaseLayout.setColumnsCount(1);
      phaseLayout.setRowsCount(1);
      LayoutGroup phaseGroup=new LayoutGroup();
      phaseGroup.setTitle("String_Node_Str");
      phaseGroup.setColumn(0);
      phaseGroup.setRow(0);
      phaseGroup.setParentLayout(phaseLayout);
      List<LayoutGroup> phaseGroups=new ArrayList<LayoutGroup>();
      phaseGroups.add(phaseGroup);
      phaseLayout.setGroups(phaseGroups);
      defaultRootPhase.setLayout(phaseLayout);
      em.persist(defaultRootPhase);
      LogFrameModel defaultLogFrame=createLogFrame(pM);
      pM.setRootPhase(defaultRootPhase);
      pM.setLogFrameModel(defaultLogFrame);
      pM=em.merge(pM);
      return mapper.map(pM,ProjectModelDTO.class);
    }
  }
  return null;
}