Buggy code:
protected static final String GET_DEFAULT_TEXT_ATTRIBUTEVALUE = "getDefaultTextAttributeValue" ; protected static final String GET_DEFAULT_TEXT = "getDefaultText" ; Issue ( ) { } protected Issue ( Module module , IssueType issueType ) throws Exception { } public static Issue getNewInstance ( Module module , IssueType issueType ) throws Exception { } public String getUniqueId ( ) throws TorqueException { } public void setUniqueId ( String id ) { } public String getFederatedId ( ) throws TorqueException { } public void setFederatedId ( String id ) { } public static class FederatedId implements Serializable { String domainId ; String prefix ; int count ; public FederatedId ( String id ) { } public FederatedId ( String domain , String prefix , int count ) { } public void setUniqueId ( String id ) { } public String getDomain ( ) { } public String getPrefix ( ) { } public int getCount ( ) { } public void setDomain ( String domainId ) { } public void setPrefix ( String prefix ) { } public void setCount ( int count ) { } } public boolean isTemplate ( ) throws Exception { } public void addComment ( Attachment attachment , ScarabUser user ) throws Exception { } public void addFile ( Attachment attachment ) throws Exception { } public void removeFile ( String index ) throws Exception { } public ScarabModule getScarabModule ( ) { } public void setScarabModule ( ScarabModule module ) { } public void setModule ( Module me ) throws TorqueException { } public Module getModule ( ) throws TorqueException { } public static Issue getIssueById ( String id ) { } public static Issue getIssueById ( Issue . FederatedId fid ) { } public SequencedHashMap getModuleAttributeValuesMap ( ) throws Exception { } public AttributeValue getAttributeValue ( Attribute attribute ) throws Exception { } public List getAttributeValues ( Attribute attribute ) throws Exception { } public boolean isAttributeValue ( AttributeValue attVal ) throws Exception { } public AttributeValue [ ] getOrderedAttributeValues ( ) throws Exception { } private AttributeValue [ ] orderAttributeValues ( Map values , Attribute [ ] attributes ) throws Exception { } public HashMap getAttributeValuesMap ( ) throws Exception { } public HashMap getAllAttributeValuesMap ( ) throws Exception { } public boolean containsMinimumAttributeValues ( ) throws Exception { } public List getEligibleUsers ( Attribute attribute ) throws Exception { } public List getUsersToEmail ( String action ) throws Exception { } public List getAssociatedUsers ( ) throws Exception { } public List getUserAttributeValues ( ) throws Exception { } public Date getCreatedDate ( ) throws Exception { } public ScarabUser getCreatedBy ( ) throws Exception { } public boolean isCreatingUser ( ScarabUser user ) throws Exception { } public Transaction getLastTransaction ( ) throws Exception { } public Date getModifiedDate ( ) throws Exception { } public ScarabUser getModifiedBy ( ) throws Exception { } public boolean isCommentsLong ( ) throws Exception { } private int getCommentsLimit ( ) throws Exception { } public List getComments ( boolean full ) throws Exception { } public List getUrls ( ) throws Exception { } public List getExistingAttachments ( ) throws Exception { } public int getHistoryLimit ( ) throws Exception { } public boolean isHistoryLong ( ) throws Exception { } public boolean isHistoryLong ( int limit ) throws Exception { } public List getActivity ( ) throws Exception { } public List getActivity ( int limit ) throws Exception { } public List getActivity ( boolean fullHistory ) throws Exception { } private List getActivity ( boolean fullHistory , int limit ) throws Exception { } public void addActivity ( Activity activity ) throws TorqueException { } public List getChildren ( ) throws Exception { } public List getParents ( ) throws Exception { } public List getAllDependencyTypes ( ) throws Exception { } public Depend getDependency ( Issue childIssue ) throws Exception { } public void save ( DBConnection dbCon ) throws TorqueException { } private int getNextIssueId ( DBConnection dbCon ) throws Exception { } private String getIdTableKey ( ) throws Exception { } private void saveIdTableKey ( DBConnection dbCon ) throws Exception { } public static List searchKeywords ( String [ ] keywords , boolean useAnd ) throws Exception { } public List getTemplateTypes ( ) throws Exception { } public IssueTemplateInfo getTemplateInfo ( ) throws Exception { } public Issue move ( Module newModule , String action , ScarabUser user ) throws Exception { } public Date getClosedDate ( ) throws Exception { } public void addVote ( ScarabUser user ) throws Exception , ScarabException { } public List getMatchingAttributeValuesList ( Module newModule ) throws Exception { } public List getMatchingAttributeValuesList ( String moduleId ) throws Exception { } public List getOrphanAttributeValuesList ( Module newModule ) throws Exception { } public List getOrphanAttributeValuesList ( String moduleId ) throws Exception { } public void assignUsers ( List newAssignees , String attachmentText , ScarabUser assigner , Attribute attribute ) throws Exception { } public void approve ( ScarabUser user , boolean approved ) throws Exception , ScarabException { Module module = getModule ( ) ; if ( user . hasPermission ( ITEM__APPROVE , module ) ) { IssueTemplateInfo templateInfo = getTemplateInfo ( ) ; templateInfo . setApproved ( true ) ; templateInfo . save ( ) ; if ( approved ) { <START_BUG> setTypeId ( GLOBAL_TEMPLATE__PK ) ; <END_BUG> } save ( ) ; } else { throw new ScarabException ( ScarabConstants . NO_PERMISSION_MESSAGE ) ; } } public void delete ( ScarabUser user ) throws Exception , ScarabException { } public AttributeValue getDefaultTextAttributeValue ( ) throws Exception { } public String getDefaultText ( ) throws Exception { } private MethodResultCache getMethodResult ( ) { } public boolean hasEnterPermission ( ScarabUser user , Module module ) throws Exception { } public boolean hasEditPermission ( ScarabUser user , Module module ) throws Exception { } public boolean hasMovePermission ( ScarabUser user , Module module ) throws Exception { } }

Fix:
setTypeId ( MODULE_TEMPLATE__PK ) ;