List of usage examples for java.lang StringBuilder charAt
char charAt(int index);
From source file:com.quinsoft.zeidon.vml.VmlOperation.java
public int ZeidonStringCopy(StringBuilder sbTarget, int targetIdx, int maxReceive, StringBuilder sbSource, int sourceIdx, int maxCopy, int maxTargetLth) { int nRC;// w w w. j a v a2 s. c om int nbrToCopy; int lth; if (sbTarget == null || sbSource == null || // gotta have strings targetIdx == 0 || sourceIdx == 0) // 1-based index { SysMessageBox(null, "JOE System Error", "ZeidonStringCopy: Invalid parameter.", 1); return (qINVALIDPARAMETER); } targetIdx--; // convert 1-based index to 0-based index for sourceIdx--; // Ensure all parms sync up and that targetIdx + maxReceive is less than maxTargetLth. if (maxReceive < -1) { SysMessageBox(null, "JOE System Error", "ZeidonStringCopy: Target string has negative length", 1); return (qMAXRECEIVEISNEGATIVE); } if (maxCopy < 0) { return (qMAXCOPYISNEGATIVE); } if ((targetIdx + maxReceive) > maxTargetLth) { SysMessageBox(null, "JOE System Error", "ZeidonStringCopy: Target string is too small", 1); return (qMAXRECEIVEEXCEEDSTARGETLEN); } // Ensure the source index does not point beyond the end of the source string. if (sourceIdx > zstrlen(sbSource)) { SysMessageBox(null, "JOE System Error", "ZeidonStringCopy: Invalid parameter (source index).", 1); return (qINVALIDPARAMETER); } // If maxReceive is -1, move the characters to the target without a null at end. if (maxReceive == -1) { if (maxCopy == 0) { maxCopy = maxTargetLth - targetIdx - 1; } while (sourceIdx < sbSource.length() && sbSource.charAt(sourceIdx) != '\0' && maxCopy > 0) { sbTarget.setCharAt(targetIdx++, sbSource.charAt(sourceIdx++)); maxCopy--; } return (sbTarget.length()); } // If maxReceive is the default of 0 then the Max is really // maxTargetLth - targetIdx - 1 (for zero-based index). if (maxReceive == 0) { maxReceive = maxTargetLth - targetIdx - 1; } if (maxCopy == 0) { maxCopy = maxReceive; } // Copy the lesser of maxReceive or maxCopy. nbrToCopy = (maxReceive < maxCopy) ? maxReceive : maxCopy; lth = sbSource.length() - sourceIdx; if (lth < nbrToCopy) { nbrToCopy = lth; // remove the "+ 1" from the original C ... requested by Kelly 2011.10.27 } sbTarget.setLength(targetIdx + nbrToCopy); while (sourceIdx < sbSource.length() && sbSource.charAt(sourceIdx) != '\0' && nbrToCopy > 0) { sbTarget.setCharAt(targetIdx++, sbSource.charAt(sourceIdx++)); nbrToCopy--; } // sbTarget.setCharAt( targetIdx, '\0' ); return sbTarget.length(); /* // Currently ZeidonStringCopy is being generated with the targetIdx and sourceIdx as 1. // The start of a string is 0. if ( targetIdx > 0 ) targetIdx--; if ( sourceIdx > 0 ) sourceIdx--; if ( maxTargetLth > 0 ) maxTargetLth--; if ( maxReceive == 0 ) maxReceive = maxTargetLth; if ( maxCopy == 0 && sbSource != null ) maxCopy = sbSource.length( ); if ( sbSource != null ) sbTarget.replace( targetIdx, maxReceive, sbSource.substring( sourceIdx, maxCopy ) ); // target.replace( targetIdx, -1, source.substring( sourceIdx ) ); nRC = sbTarget.length( ); if ( nRC > maxTargetLth ) { sbTarget.setLength( maxTargetLth ); nRC = maxTargetLth; } return nRC; */ }
From source file:io.github.jeddict.orm.generator.compiler.def.VariableDefSnippet.java
public String getJaxbAnnotationSnippet() { StringBuilder snippet = new StringBuilder(); if (getJaxbVariableType() == JaxbVariableType.XML_ATTRIBUTE || getJaxbVariableType() == JaxbVariableType.XML_LIST_ATTRIBUTE) { if (getJaxbVariableType() == JaxbVariableType.XML_LIST_ATTRIBUTE) { snippet.append(AT + JAXB_XML_LIST).append(NEW_LINE).append(TAB); }/* ww w .j a va 2s.c o m*/ snippet.append(AT + JAXB_XML_ATTRIBUTE); JaxbMetadata md = this.getJaxbMetadata(); if (StringUtils.isNotBlank(md.getName()) || StringUtils.isNotBlank(md.getNamespace()) || md.getRequired()) { snippet.append(OPEN_PARANTHESES); if (StringUtils.isNotBlank(md.getName())) { snippet.append("name = \"").append(md.getName()).append("\", "); } if (StringUtils.isNotBlank(md.getNamespace())) { snippet.append("namespace = \"").append(md.getNamespace()).append("\", "); } if (md.getRequired()) { snippet.append("required = ").append(md.getRequired()).append(", "); } snippet.setLength(snippet.length() - 2); snippet.append(")"); } } else if (getJaxbVariableType() == JaxbVariableType.XML_ELEMENT || getJaxbVariableType() == JaxbVariableType.XML_LIST_ELEMENT || getJaxbVariableType() == JaxbVariableType.XML_ELEMENT_WRAPPER) { if (getJaxbVariableType() == JaxbVariableType.XML_LIST_ELEMENT) { snippet.append(AT + JAXB_XML_LIST).append(NEW_LINE).append(TAB); } else if (getJaxbVariableType() == JaxbVariableType.XML_ELEMENT_WRAPPER) { snippet.append(AT + JAXB_XML_ELEMENT_WRAPPER); JaxbMetadata wmd = this.getJaxbWrapperMetadata(); if (StringUtils.isNotBlank(wmd.getName()) || StringUtils.isNotBlank(wmd.getNamespace()) || wmd.getRequired() || wmd.getNillable()) { snippet.append(OPEN_PARANTHESES); if (wmd.getName() != null && !wmd.getName().isEmpty()) { snippet.append("name = \"").append(wmd.getName()).append("\", "); } if (StringUtils.isNotBlank(wmd.getNamespace())) { snippet.append("namespace = \"").append(wmd.getNamespace()).append("\", "); } if (wmd.getRequired()) { snippet.append("required = ").append(wmd.getRequired()).append(", "); } if (wmd.getNillable()) { snippet.append("nillable = ").append(wmd.getNillable()).append(", "); } snippet.setLength(snippet.length() - 2); snippet.append(")"); } snippet.append(NEW_LINE).append(TAB); } snippet.append(AT + JAXB_XML_ELEMENT); JaxbMetadata md = this.getJaxbMetadata(); if (StringUtils.isNotBlank(md.getName()) || StringUtils.isNotBlank(md.getNamespace()) || md.getRequired() || md.getNillable()) { snippet.append(OPEN_PARANTHESES); if (md.getName() != null && !md.getName().isEmpty()) { snippet.append("name = \"").append(md.getName()).append("\", "); } if (StringUtils.isNotBlank(md.getNamespace())) { snippet.append("namespace = \"").append(md.getNamespace()).append("\", "); } if (md.getRequired()) { snippet.append("required = ").append(md.getRequired()).append(", "); } if (md.getNillable()) { snippet.append("nillable = ").append(md.getNillable()).append(", "); } snippet.setLength(snippet.length() - 2); snippet.append(")"); } } else if (getJaxbVariableType() == JaxbVariableType.XML_VALUE || getJaxbVariableType() == JaxbVariableType.XML_LIST_VALUE) { if (getJaxbVariableType() == JaxbVariableType.XML_LIST_VALUE) { snippet.append(AT + JAXB_XML_LIST).append(NEW_LINE).append(TAB); } snippet.append(AT + JAXB_XML_VALUE); } else if (getJaxbVariableType() == JaxbVariableType.XML_TRANSIENT) { snippet.append(AT + JAXB_XML_TRANSIENT); } else if (getJaxbVariableType() == JaxbVariableType.XML_INVERSE_REFERENCE && getRelationDef() != null) { String mappedBy = getRelationDef().getTargetField();//both side are applicable so targetField is used instead of mappedBy if (mappedBy != null) { snippet.append(String.format(AT + JAXB_XML_INVERSE_REFERENCE + "(mappedBy=\"%s\")", mappedBy)); } } else if (getJaxbVariableType() == JaxbVariableType.XML_ELEMENT_REF) { snippet.append(AT + JAXB_XML_ELEMENT_REF); JaxbMetadata md = this.getJaxbMetadata(); if (StringUtils.isNotBlank(md.getName()) || StringUtils.isNotBlank(md.getNamespace()) || md.getRequired()) { snippet.append(OPEN_PARANTHESES); if (StringUtils.isNotBlank(md.getName())) { snippet.append("name = \"").append(md.getName()).append("\", "); } if (StringUtils.isNotBlank(md.getNamespace())) { snippet.append("namespace = \"").append(md.getNamespace()).append("\", "); } if (md.getRequired()) { snippet.append("required = ").append(md.getRequired()).append(", "); } snippet.setLength(snippet.length() - 2); snippet.append(")"); } } else { if (isPrimaryKey()) { // snippet.append("@XmlID").append(NEW_LINE).append(TAB); } else if (getRelationDef() != null) { if (getRelationDef() instanceof OneToOneSnippet) { OneToOneSnippet otoSnippet = (OneToOneSnippet) getRelationDef(); if (otoSnippet.getMappedBy() != null && !otoSnippet.getMappedBy().trim().isEmpty()) { snippet.append(AT + JAXB_XML_TRANSIENT); } else { // snippet.append("@XmlIDREF").append(NEW_LINE).append(TAB); } } else if (getRelationDef() instanceof OneToManySnippet) { OneToManySnippet otmSnippet = (OneToManySnippet) getRelationDef(); if (otmSnippet.getMappedBy() != null && !otmSnippet.getMappedBy().trim().isEmpty()) { snippet.append(AT + JAXB_XML_TRANSIENT); } else { // snippet.append("@XmlIDREF").append(NEW_LINE).append(TAB); } } else if (getRelationDef() instanceof ManyToOneSnippet) { // snippet.append("@XmlIDREF").append(NEW_LINE).append(TAB); } else if (getRelationDef() instanceof ManyToManySnippet) { ManyToManySnippet mtmSnippet = (ManyToManySnippet) getRelationDef(); if (mtmSnippet.getMappedBy() != null && !mtmSnippet.getMappedBy().trim().isEmpty()) { snippet.append(AT + JAXB_XML_TRANSIENT); } else { // snippet.append("@XmlIDREF").append(NEW_LINE).append(TAB); } } } } int snippetLength = snippet.length(); //Remove NEW_LINE and TAB if (snippetLength > 6 && snippet.charAt(snippetLength - 5) == '\n') { snippet.setLength(snippetLength - 5); } return snippet.toString(); }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
public static int SysAppendcDirSep(StringBuilder sbDirectoryName) { String s = sbDirectoryName.toString(); s = s.replace('\\', '/'); int nLth = s.length(); sbDirectoryName.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer. sbDirectoryName.append(s);//w w w . j a v a 2 s .co m if (nLth > 1 && sbDirectoryName.charAt(nLth - 1) != '/') { sbDirectoryName.insert(nLth++, '/'); } return nLth; }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
public int TruncateName8(StringBuilder sbName) { int k;/*from w ww .j a va 2 s .co m*/ int nLth = sbName.length() < 8 ? sbName.length() : 8; for (k = 0; k < nLth; k++) { if (sbName.charAt(k) == 0) { break; } if (sbName.charAt(k) == ' ') { sbName.setCharAt(k, '_'); } } sbName.setLength(k); return (k); }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
public int CommitLPLR(View vTZCMLPLO) { StringBuilder sbFileName = new StringBuilder(); String szWork;/*from w ww . jav a 2 s . c om*/ StringBuilder sbLPLR_Name = new StringBuilder(); int k; szWork = GetStringFromAttribute(vTZCMLPLO, "LPLR", "ExecDir"); SysConvertEnvironmentString(sbFileName, szWork); SysAppendcDirSep(sbFileName); GetStringFromAttribute(sbLPLR_Name, vTZCMLPLO, "LPLR", "Name"); if (sbLPLR_Name.length() > 8) { sbLPLR_Name.setLength(8); } for (k = 0; k < sbLPLR_Name.length(); k++) { if (sbLPLR_Name.charAt(k) == ' ') { sbLPLR_Name.setCharAt(k, '_'); } } zstrcat(sbFileName, sbLPLR_Name.toString()); zstrcat(sbFileName, ".XLP"); zgSortEntityWithinParent(zASCENDING, vTZCMLPLO, "W_MetaType", "Type", ""); return (CommitOI_ToFile(vTZCMLPLO, sbFileName.toString(), zSINGLE)); // return( CommitOI_ToFile( vTZCMLPLO, sbFileName, zBINARY | zSINGLE | zINCREMENTAL ) ); }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
private int fnCommitMetaOI(View vSubtask, View vMOI, int nType, View vActiveMetas, View vZeidonCM, View vLPLR) throws IOException { int nRC, nEntityType; boolean bNewMeta; int ReferViewsActive, ReferOI_Active; zVIEW vWork1 = new zVIEW(); zVIEW CM_View = new zVIEW(); zVIEW MOI_ExecView = new zVIEW(); zVIEW IncludeView = new zVIEW(); zVIEW WKS_View = new zVIEW(); zVIEW vTempLPLR = new zVIEW(); String szMetaOI_Name; // protect from long name StringBuilder sbMetaOI_File = new StringBuilder(); // protect from long name String szSubEntityName;//w ww .j a va2 s . com String szSubOI_Name; StringBuilder sbObjectName = new StringBuilder(); int lSubType; int lMetaOI_ZKey; int lSubOI_ZKey; StringBuilder sbFileSpec = new StringBuilder(); // String szTempFileName[ 2 * zMAX_FILESPEC_LTH + 1 ]; // String szTempFileName[ zMAX_FILENAME_LTH + 1 ]; String szDesc; StringBuilder sbMsg = new StringBuilder(); String szTimestamp = ""; int lTaskID; long lMOI_InstanceID; String szCM_ViewName; StringBuilder sbNamedView = new StringBuilder(); TraceLineS("fnCommitMetaOI", "======================================="); ReferOI_Active = 0; nEntityType = fnVerifyType(nType); if (nEntityType < 0) { return -1; } szMetaOI_Name = GetStringFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, SRC_CMOD[nType].szOD_NAME); // If the view is read-only, then we can't commit it. nRC = MiGetUpdateForView(vMOI); if ((nEntityType == CM_REFER_TYPE) || (nRC == 0)) { zstrcpy(sbMsg, "The meta passed to CommitMetaOI, "); zstrcat(sbMsg, szMetaOI_Name); zstrcat(sbMsg, "is not an Active Meta. See Trace"); TraceLineS("Zeidon Configuration Management", sbMsg.toString()); TraceLineI(" Type passed is: ", nType); MessageSend(vSubtask, "CM00422", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } // Get the ZKey for the OI we are about to commit. lMetaOI_ZKey = GetIntegerFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, "ZKey"); // Position on the correct W_MetaType. If it doesn't exist, create one. if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType, "") != zCURSOR_SET) { // DGC? - Why are we creating an entity? Shouldn't it already exist? // If we are commiting an OI, then it has been activated and therefore // the MetaType entity should have been created. // It does already exist for reports (so we don't get here ... DKS). CreateEntity(vLPLR, "W_MetaType", zPOS_AFTER); SetAttributeFromInteger(vLPLR, "W_MetaType", "Type", nType); } // Position on the correct W_MetaType. If it doesn't exist, create one. if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType + 2000, "") != zCURSOR_SET) { // DGC? - Why are we creating an entity? Shouldn't it already exist? // If we are commiting an OI, then it has been activated and therefore // the MetaType entity should have been created. // It does already exist for reports (so we don't get here ... DKS). CreateEntity(vLPLR, "W_MetaType", zPOS_AFTER); SetAttributeFromInteger(vLPLR, "W_MetaType", "Type", nType + 2000); } if (SetCursorFirstEntityByAttr(vActiveMetas, "LPLR", "Name", vLPLR, "LPLR", "Name", "") != zCURSOR_SET) { MessageSend(vSubtask, "CM00423", "Configuration Management", "Unable to locate LPLR Entity in ZeidonCM for CommitMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaType", "Type", nType, "") != zCURSOR_SET) { CreateEntity(vActiveMetas, "W_MetaType", zPOS_AFTER); SetAttributeFromInteger(vActiveMetas, "W_MetaType", "Type", nType); } // Now check for Duplicately named Metas. if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") < zCURSOR_SET) { nRC = fnCheckForDuplicateName(vMOI, vLPLR, szMetaOI_Name, lMetaOI_ZKey, 1); // Adding New Meta } else { if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "UpdateInd", 3) == 0) { MessageSend(vSubtask, "CM00424", "Configuration Management", "Deleted Meta Def passed to CommitMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } nRC = fnCheckForDuplicateName(vMOI, vLPLR, szMetaOI_Name, lMetaOI_ZKey, 0); // Updating Meta } if (nRC == -1) { return -1; } if (nRC == 1) // duplicate found and renamed { szMetaOI_Name = GetStringFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, SRC_CMOD[nType].szOD_NAME); } if (nType == zSOURCE_DOMAINGRP_META || nType == zSOURCE_GOPGRP_META) { // For Global Operation Groups and Domain Groups, check each Global // Operation or Domain within the Group to make sure there are no // duplicates. if (nType == zSOURCE_DOMAINGRP_META) { szSubEntityName = "Domain"; lSubType = zSOURCE_DOMAIN_META; } else { szSubEntityName = "Operation"; lSubType = zSOURCE_GO_META; } CreateViewFromViewForTask(vTempLPLR, vLPLR, vSubtask); SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType + 2000, ""); nRC = SetCursorFirstEntity(vMOI, szSubEntityName, ""); while (nRC >= zCURSOR_SET) { szSubOI_Name = GetStringFromAttribute(vMOI, szSubEntityName, "Name"); lSubOI_ZKey = GetIntegerFromAttribute(vMOI, szSubEntityName, "ZKey"); nRC = fnCheckForDuplicateName(vMOI, vTempLPLR, szSubOI_Name, lSubOI_ZKey, 0); if (nRC == -1) { return -1; } nRC = SetCursorNextEntity(vMOI, szSubEntityName, ""); } // For Global Operation Groups and Domain Groups, loop through each // operation or domain in the Group and update the names, in case any // of those names were changed. Do this first for zSOURCE type and // then for zREFER type. for (nRC = SetCursorFirstEntity(vMOI, szSubEntityName, ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vMOI, szSubEntityName, "")) { szSubOI_Name = GetStringFromAttribute(vMOI, szSubEntityName, "Name"); lSubOI_ZKey = GetIntegerFromAttribute(vMOI, szSubEntityName, "ZKey"); // zSOURCE type SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType, ""); nRC = SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaDef", "CPLR_ZKey", lSubOI_ZKey, ""); if (nRC >= zCURSOR_SET) { SetAttributeFromString(vTempLPLR, "W_MetaDef", "Name", szSubOI_Name); } // zREFER type SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType + 2000, ""); nRC = SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaDef", "CPLR_ZKey", lSubOI_ZKey, ""); if (nRC >= zCURSOR_SET) { SetAttributeFromString(vTempLPLR, "W_MetaDef", "Name", szSubOI_Name); } } DropView(vTempLPLR); } // lTaskID = SysGetTaskFromView( vMOI ); lTaskID = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId()); if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) { // New Meta bNewMeta = true; } else { // a W_MetaDef exists for this OI in the CM Active list bNewMeta = false; szCM_ViewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName"); if (GetViewByName(CM_View, szCM_ViewName + ".u", vZeidonCM, zLEVEL_SUBTASK) < 0) { // If such a named view was not found, then the meta was not opened // for update. MessageSend(vSubtask, "CM00425", "Configuration Management", "The Meta being committed was not Activated for update.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } lMOI_InstanceID = MiGetInstanceID_ForView(CM_View); if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID) != 0) { if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "TaskID", 0) == 0) { MessageSend(vSubtask, "CM00426", "Configuration Management", "The Meta passed to CommitMetaOI was not opened for Update!", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } else { if (MiGetInstanceID_ForView(vMOI) != lMOI_InstanceID) { zstrcpy(sbMsg, "The View to the Meta passed to CommitMetaOI" + "\nis not to the the same Object Instance for" + "\nwhich the view was originally opened."); MessageSend(vSubtask, "CM00427", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } } } // Replace the last String in szCM_ViewName with an 'r'. if (GetViewByName(CM_View, szCM_ViewName + 'r', vZeidonCM, zLEVEL_SUBTASK) > 0) { // REFER OI of Meta exists - Check if there are Views to it ReferOI_Active = 1; ReferViewsActive = 0; lMOI_InstanceID = MiGetInstanceID_ForView(CM_View); nRC = DriverApplication.SfGetFirstNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); while (nRC > 0) { if (sbNamedView.substring(0, 5).compareTo("__CM.") == 0) { zVIEW vWork2 = new zVIEW(); StringBuilder sbTaskView = new StringBuilder(); nRC = DriverApplication.SfGetFirstNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK); while (nRC > 0) { if (sbTaskView.charAt(0) == 'r') { if (MiGetInstanceID_ForView(vWork2) == lMOI_InstanceID) { ReferViewsActive = 1; break; } } nRC = DriverApplication.SfGetNextNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK); } } if (ReferViewsActive == 1) { return 0; } nRC = DriverApplication.SfGetNextNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); } DropObjectInstance(CM_View); } } if (GetViewByName(WKS_View, "TZCMWKSO", vZeidonCM, zLEVEL_SUBTASK) <= 0) { return -1; } fnGetDirectorySpec(vMOI, sbFileSpec, nType); switch (nType) { case zSOURCE_VOR_META: zltoxa(lMetaOI_ZKey, sbMetaOI_File); zstrcat(sbFileSpec, sbMetaOI_File.toString()); break; default: if (bNewMeta == false && CompareAttributeToString(vActiveMetas, "W_MetaDef", "Name", szMetaOI_Name) != 0) { // FileName change nRC = zstrlen(sbFileSpec); StringBuilder sb = new StringBuilder(GetStringFromAttribute(vActiveMetas, "W_MetaDef", "Name")); TruncateName8(sb); sbFileSpec.append(sb); sbFileSpec.append(SRC_CMOD[nType].szOD_EXT); SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE); if (nType == zSOURCE_DIALOG_META || nType == zSOURCE_LOD_META) { GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); nRC = zstrlen(sbFileSpec); sb.setLength(0); sb.append(GetStringFromAttribute(vActiveMetas, "W_MetaDef", "Name")); TruncateName8(sb); sbFileSpec.append(sb); if (nType == zSOURCE_LOD_META) { zstrcat(sbFileSpec, ".XOD"); } else { zstrcat(sbFileSpec, ".XWD"); } SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE); } fnGetDirectorySpec(vLPLR, sbFileSpec, nType); } zstrcpy(sbMetaOI_File, szMetaOI_Name); TruncateName8(sbMetaOI_File); zstrcat(sbFileSpec, sbMetaOI_File); break; // default. } // switch ( nType )... zstrcat(sbFileSpec, SRC_CMOD[nType].szOD_EXT); szDesc = GetVariableFromAttribute(0, zTYPE_STRING, 255, vMOI, SRC_CMOD[nType].szOD_ROOT, "Desc", "", 0); // Commit the XWD/XRA if a Dialog Meta. if (nType == zSOURCE_DIALOG_META || nType == zSOURCE_REPORT_META || nType == zSOURCE_XSLT_META) { zVIEW vDialogSubtask = new zVIEW(); GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, sbMetaOI_File); GetViewByName(vDialogSubtask, "TZCM_DialogSubtask", vSubtask, zLEVEL_TASK); // MOI_ExecView = ConvertDialog( vDialogSubtask, vMOI, "" ); if (nType == zSOURCE_DIALOG_META) { StringBuilder sbRemotePath = new StringBuilder(); View vXRA; int nLth; nLth = zstrlen(sbFileSpec); MOI_ExecView.setView(ConvertDialog(vSubtask, vMOI, "")); zstrcat(sbFileSpec, ".XWD"); } else if (nType == zSOURCE_REPORT_META) { // Create the Report executable file (.XRP) in the executable meta // directory, which is a flattened version of the Report source // (.PRP) in the source meta directory. The executable is flattened // by putting all controls to the Control level (moving CtrlCtrl // entities directly under the appropriate Group entities as Control // entities ... no recursive relationships). /* fnGetDirectorySpec( szFileSpec, nType ); zstrcpy( szMetaOI_File, szMetaOI_Name ); TruncateName8( szMetaOI_File ); zstrcat( szFileSpec, szMetaOI_File ); zstrcat( szFileSpec, SRC_CMOD[ nType ].szOD_EXT ); GetViewByName( &vTempLPLR, "TaskLPLR", vSubtask, zLEVEL_TASK ); GetStringFromAttribute( szFileSpecExec, vTempLPLR, "LPLR", "ExecDir" ); SysAppendcDirSep( szFileSpecExec ); zstrcat( szFileSpecExec, szMetaOI_File ); zstrcat( szFileSpecExec, ".XRP" ); SysCopyFile( szFileSpec, szFileSpecExec, true ); break; */ MOI_ExecView.setView(ConvertReport(vLPLR, vMOI, "")); zstrcat(sbFileSpec, ".XRP"); } else { // Create the XSLT executable file (.XSL) in the executable meta // directory, which is a flattened version of the Report source // (.PSL) in the source meta directory. The executable is flattened // by putting all controls to the Control level (moving CtrlCtrl // entities directly under the appropriate Group entities as Control // entities ... no recursive relationships). MOI_ExecView.setView(ConvertXSLT(vLPLR, vMOI, "")); zstrcat(sbFileSpec, ".XSL"); } nRC = CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE); if (nRC != 0) { zstrcpy(sbMsg, "CommitMetaOI failed trying to save "); zstrcat(sbMsg, sbFileSpec); MessageSend(vSubtask, "CM00428", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } DropObjectInstance(MOI_ExecView); fnGetDirectorySpec(vMOI, sbFileSpec, nType); zstrcat(sbFileSpec, sbMetaOI_File); zstrcat(sbFileSpec, SRC_CMOD[nType].szOD_EXT); } // Decide what control flags should be used based on the current file // version and the INI settings. nRC = fnAllowBinaryDataInSourceMetaFiles(vLPLR); if (nRC == 1) { // Keep it the same format. if (MiCompareOI_ToRelease(vMOI, releaseCompatible) <= 0) { MiSetOI_ReleaseForView(vMOI, releaseCompatible); nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE); } else { MiSetOI_ReleaseForView(vMOI, releaseCurrent); nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE | zENCODE_BLOBS | zNO_NULL_STRING_TERM); } } else if (nRC == 2) { // Force it to compatibility format. MiSetOI_ReleaseForView(vMOI, releaseCompatible); nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE); } else { // Use the current release version of the software. MiSetOI_ReleaseForView(vMOI, releaseCurrent); nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE | zENCODE_BLOBS | zNO_NULL_STRING_TERM); } if (nRC != 0) { zstrcpy(sbMsg, "CommitMetaOI failed trying to save "); zstrcat(sbMsg, sbFileSpec); MessageSend(vSubtask, "CM00429", "Configuration Management", sbMsg.toString(), zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } if (ReferOI_Active == 1) { if (nType != zSOURCE_DIALOG_META && nType != zSOURCE_REPORT_META && nType != zSOURCE_XSLT_META && nType != zSOURCE_UIS_META) { ActivateMetaOI_ByZKey(vSubtask, CM_View, vWork1, nType + 2000, zLEVEL_SUBTASK, lMetaOI_ZKey, 0); // If we are committing a DomainGroup, relink it with any ERDs // that are currently in memory. if (nType == zSOURCE_DOMAINGRP_META) { zVIEW vDomainGrp = new zVIEW(); nRC = DriverApplication.SfGetFirstNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); while (nRC > 0) { if (sbNamedView.substring(0, 5).compareTo("__CM.") == 0) { sbObjectName.setLength(0); } else { MiGetObjectNameForView(sbObjectName, vWork1); } if (zstrcmp(sbObjectName.toString(), "TZEREMDO") == 0) { // Loop through all Domains in ER and Relink any of those // Domains to the current DomainGrp that are a part of that // DomainGrp. CreateViewFromViewForTask(vDomainGrp, vMOI, vSubtask); for (nRC = SetCursorFirstEntity(vWork1, "Domain", "EntpER_Model"); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vWork1, "Domain", "EntpER_Model")) { nRC = SetCursorFirstEntityByAttr(vDomainGrp, "Domain", "ZKey", vWork1, "Domain", "ZKey", ""); if (nRC >= 0) { RelinkInstanceToInstance(vWork1, "Domain", vDomainGrp, "Domain"); } } DropView(vDomainGrp); } nRC = DriverApplication.SfGetNextNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); } } DropMetaOI(vSubtask, CM_View); } } // Reset to correct W_MetaType in case of PostActivate having changed // position. SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType + 2000, ""); if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) { // Corresponding W_MetaDef Not Found - New Meta. CreateEntity(vLPLR, "W_MetaDef", zPOS_AFTER); SetAttributeFromInteger(vLPLR, "W_MetaDef", "Status", 1); } SetAttributeFromString(vLPLR, "W_MetaDef", "Name", szMetaOI_Name); szTimestamp = SysGetDateTime(szTimestamp); SetAttributeFromString(vLPLR, "W_MetaDef", "LastUpdateDate", szTimestamp); SetAttributeFromString(vLPLR, "W_MetaDef", "LastSyncDate", szTimestamp); SetAttributeFromInteger(vLPLR, "W_MetaDef", "UpdateInd", 2); SetAttributeFromInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey); SetAttributeFromString(vLPLR, "W_MetaDef", "Desc", szDesc); // Include W_MetaDef to Active MetaDef if not already there. CreateViewFromViewForTask(IncludeView, vLPLR, vSubtask); SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType, ""); if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) { // New IncludeSubobjectFromSubobject(vLPLR, "W_MetaDef", IncludeView, "W_MetaDef", zPOS_AFTER); //BL, 1999.12.29 if check in, then this Meta does exists in // View vActiveMetas if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) { IncludeSubobjectFromSubobject(vActiveMetas, "W_MetaDef", vLPLR, "W_MetaDef", zPOS_AFTER); } szCM_ViewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName"); CreateViewFromViewForTask(CM_View, vMOI, vSubtask); SetNameForView(CM_View, szCM_ViewName + ".u", vZeidonCM, zLEVEL_SUBTASK); SetAttributeFromInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID); } DropView(IncludeView); zgSortEntityWithinParent(zASCENDING, vLPLR, "W_MetaDef", "Name", ""); switch (nType) { case zSOURCE_ERD_META: // Make sure that all LODs are eliminated from the Active Metas list. if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaType", "Type", zSOURCE_LOD_META, "") >= zCURSOR_SET) { for (nRC = SetCursorFirstEntity(vActiveMetas, "W_MetaDef", ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vActiveMetas, "W_MetaDef", "")) { GetStringFromAttribute(sbNamedView, vActiveMetas, "W_MetaDef", "CM_ViewName"); zstrcat(sbNamedView, ".r"); if (GetViewByName(CM_View, sbNamedView.toString(), vZeidonCM, zLEVEL_SUBTASK) > 0) { DropObjectInstance(CM_View); } ExcludeEntity(vActiveMetas, "W_MetaDef", zREPOS_NONE); } } break; case zSOURCE_LOD_META: SetNameForView(vMOI, "TZZOLODO", vSubtask, zLEVEL_TASK); oTZZOXODO_SaveXOD(vSubtask, vMOI); // Get access to the newly built XOD. if (GetViewByName(MOI_ExecView, "TZZOXODO", vSubtask, zLEVEL_TASK) < 1) { zstrcpy(sbMsg, "(fnCommitMetaOI) Unable to Access XOD. XOD must be opened."); MessageSend(vSubtask, "CM00430", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } // Save the XOD to a file. GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, sbMetaOI_File); zstrcat(sbFileSpec, ".XOD"); if (CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE) != 0) { zstrcpy(sbMsg, "Commit of XOD failed."); MessageSend(vSubtask, "CM00431", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } break; case zSOURCE_PENV_META: MOI_ExecView.setView(CreatePE_ExecVersion(vLPLR, vMOI)); GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, "ZEIDON.XPE"); if (CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE) != 0) { zstrcpy(sbMsg, "Commit of Executable Presentation Environment -\n"); zstrcpy(sbMsg, sbFileSpec); zstrcpy(sbMsg, " failed."); MessageSend(vSubtask, "CM00432", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } break; case zSOURCE_GOPGRP_META: case zSOURCE_DOMAINGRP_META: { zVIEW vWorkRefer = new zVIEW(); zVIEW vWorkSource = new zVIEW(); int lStatus; int lSourceItem; int lReferItem; String lpchItemName; String lpchGroupName; // We have just committed a group (e.g. DomainGroup). We need to // create a W_MetaDef entity for each item in the group (e.g. // domain) so that CM can then activate an item by name. // The logic is the same for both domain and GO groups, but some of // the values are different, so we set up some variables. if (nType == zSOURCE_DOMAINGRP_META) { lReferItem = zREFER_DOMAIN_META; lSourceItem = zSOURCE_DOMAIN_META; lpchItemName = "Domain"; // Name of the item ent. lpchGroupName = "DomainGroup"; // Name of group entity. } else { lReferItem = zREFER_GO_META; lSourceItem = zSOURCE_GO_META; lpchItemName = "Operation"; // Name of the item ent. lpchGroupName = "GlobalOperationGroup"; // Name of group entity. } CreateViewFromViewForTask(vWorkRefer, vLPLR, vSubtask); CreateViewFromViewForTask(vWorkSource, vLPLR, vSubtask); // #ifdef DEBUG // SetNameForView( vWorkRefer, "WorkRefer", vSubtask, zLEVEL_TASK ); // SetNameForView( vWorkSource, "WorkSource", vSubtask, zLEVEL_TASK ); // #endif // Get the value of W_MetaDef.Status from the group W_MetaDef. If the // attribute isn't set then set lStatus = -1. Otherwise lStatus will // be 0 or 1. Later on when we're setting W_MetaDef.Status for the // domain, if lStatus = -1 then we'll leave W_MetaDef.Status as null. // NOTE: We are assuming that the view vLPLR is pointing to the // correct group W_MetaDef. MutableInt mi = new MutableInt(); if (GetIntegerFromAttribute(mi, vLPLR, "W_MetaDef", "Status") < 0) { lStatus = -1; } else { lStatus = mi.intValue(); } // Find the item Meta type (eg Domain). If it doesn't exist, create it. if (SetCursorFirstEntityByInteger(vWorkSource, "W_MetaType", "Type", lSourceItem, "") != zCURSOR_SET) { CreateEntity(vWorkSource, "W_MetaType", zPOS_LAST); SetAttributeFromInteger(vWorkSource, "W_MetaType", "Type", lSourceItem); } // Same for REFER if (SetCursorFirstEntityByInteger(vWorkRefer, "W_MetaType", "Type", lReferItem, "") != zCURSOR_SET) { CreateEntity(vWorkRefer, "W_MetaType", zPOS_LAST); SetAttributeFromInteger(vWorkRefer, "W_MetaType", "Type", lReferItem); } // Loop through each of the items in the MetaDef, looking for items // with GroupName that matches the name of the group. If it doesn't // exist in the Meta OI, then it's been deleted from the Meta and it // needs to be deleted from the item list. for (nRC = SetCursorFirstEntityByAttr(vWorkRefer, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name", ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntityByAttr(vWorkRefer, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name", "")) { // Try to find the item in the Meta OI by ZKey. If it doesn't exist, // then it no longer exists in the Meta OI and needs to be deleted // from the LPLR. if (SetCursorFirstEntityByAttr(vMOI, lpchItemName, "ZKey", vWorkRefer, "W_MetaDef", "CPLR_ZKey", "") != zCURSOR_SET) { DeleteEntity(vWorkRefer, "W_MetaDef", zREPOS_NONE); } } // Loop through each of the items in the group. If it doesn't // exist in the Refer LPLR, add it to both source and refer. for (nRC = SetCursorFirstEntity(vMOI, lpchItemName, ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vMOI, lpchItemName, "")) { // Try to find the W_MetaDef by ZKey. If it doesn't exist, then it // needs to be created. if (SetCursorFirstEntityByAttr(vWorkRefer, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey", "") != zCURSOR_SET) { // Create entity in refer meta type CreateEntity(vWorkRefer, "W_MetaDef", zREPOS_LAST); SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "Name", vMOI, lpchItemName, "Name"); SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey"); SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name"); if (lStatus >= 0) { SetAttributeFromInteger(vWorkRefer, "W_MetaDef", "Status", lStatus); } // Create entity in source meta type CreateEntity(vWorkSource, "W_MetaDef", zREPOS_LAST); SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "Name", vMOI, lpchItemName, "Name"); SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey"); SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name"); // If lStatus is not -1, then we need to set status in W_MetaDef. if (lStatus >= 0) { SetAttributeFromInteger(vWorkSource, "W_MetaDef", "Status", lStatus); } } } // for... DropView(vWorkRefer); DropView(vWorkSource); break; } // case zSOURCE_DOMAINGRP_META... } // switch ( nType )... if (CommitLPLR(vLPLR) == 0) { if (CommitWorkstation(WKS_View) == 0) { return (1); } } return -1; }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
public void SysConvertEnvironmentString(StringBuilder sbTarget, String source) { int targetLength = 0; int pos;// ww w. ja v a2s.com int k; sbTarget.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer. for (k = 0; k < source.length(); k++) { if (source.charAt(k) != '%') { sbTarget.append(source.charAt(k)); targetLength++; continue; } k++; // bump up to skip past % pos = k; while (k < source.length() && source.charAt(k) != '%') { k++; } if (k < source.length() && source.charAt(k) == '%') // found terminating % { // String s = SysGetEnvVar( s, source.substring( pos, k ), 256 ); String s = JoeUtils.getEnvProperty(source.substring(pos, k), false); sbTarget.append(s); targetLength += s.length(); } } sbTarget.setLength(targetLength); for (k = 0; k < targetLength; k++) { if (sbTarget.charAt(k) == '\\') { sbTarget.setCharAt(k, '/'); } } }
From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java
public int DeleteMetaOI(View vSubtask, View vListView, int nType) throws IOException { int nEntityType; int nWorkType; int nReferOI_Active = 0; int nReferViewsActive = 0; int lTaskID;/*from w ww .j av a 2s.co m*/ long lMOI_InstanceID; int lMetaOI_ZKey; zVIEW vTaskLPLR = new zVIEW(); zVIEW vMeta = new zVIEW(); zVIEW vLPLR = new zVIEW(); zVIEW vLPLR2 = new zVIEW(); zVIEW vZeidonCM = new zVIEW(); zVIEW vActiveMetas = new zVIEW(); zVIEW vActiveList = new zVIEW(); zVIEW vWork1 = new zVIEW(); zVIEW vWork2 = new zVIEW(); zVIEW CM_View = new zVIEW(); zVIEW vVOR = new zVIEW(); zVIEW vVOR_LPLR = new zVIEW(); StringBuilder sbMetaOI_Name = new StringBuilder(); String szEntityName; String szCM_ViewName; StringBuilder sbNamedView = new StringBuilder(); StringBuilder sbTaskView = new StringBuilder(); StringBuilder sbFileSpec = new StringBuilder(); StringBuilder sbErrMsg = new StringBuilder(); int nRC, nRC2; nEntityType = fnVerifyType(nType); if (nEntityType < 0) { return -1; } GetViewByName(vTaskLPLR, "TaskLPLR", vSubtask, zLEVEL_TASK); CreateViewFromViewForTask(vLPLR, vTaskLPLR, vSubtask); if (GetViewByName(vZeidonCM, "ZeidonCM", vSubtask, zLEVEL_APPLICATION) <= 0) { MessageSend(vSubtask, "CM00448", "Configuration Management", "Unable to locate ZeidonCM in DeleteMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } if (GetViewByName(vActiveMetas, "OpenCM_Metas", vZeidonCM, zLEVEL_SUBTASK) <= 0) { MessageSend(vSubtask, "CM00449", "Configuration Management", "Unable to locate OpenCM_Metas in DeleteMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } CreateViewFromViewForTask(vActiveList, vActiveMetas, vSubtask); if (nEntityType == CM_ACTIVE_TYPE) nWorkType = nType; else nWorkType = nType - 2000; lMetaOI_ZKey = GetIntegerFromAttribute(vListView, "W_MetaDef", "CPLR_ZKey"); sbMetaOI_Name.append(GetStringFromAttribute(vListView, "W_MetaDef", "Name")); nRC = SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "LPLR"); if (nRC < zCURSOR_SET) { MessageSend(vSubtask, "CM00450", "Configuration Management", "Component to be Deleted not found in the LPLR.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } if (CompareAttributeToInteger(vLPLR, "W_MetaType", "Type", nWorkType) != 0) { MessageSend(vSubtask, "CM00451", "Configuration Management", "Component to be Deleted not active in the LPLR.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } if (CompareAttributeToString(vLPLR, "W_MetaDef", "Name", sbMetaOI_Name.toString()) != 0) { MessageSend(vSubtask, "CM00452", "Configuration Management", "Component to be Deleted found in the LPLR under a different name", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } nRC = SetCursorFirstEntityByEntityCsr(vActiveList, "W_MetaDef", vLPLR, "W_MetaDef", "LPLR"); if (nRC >= zCURSOR_SET) { lTaskID = GetIntegerFromAttribute(vActiveList, "W_MetaDef", "TaskID"); if (lTaskID != 0) { szCM_ViewName = GetStringFromAttribute(vActiveList, "W_MetaDef", "CM_ViewName"); if (GetViewByName(CM_View, szCM_ViewName + ".u", vZeidonCM, zLEVEL_SUBTASK) > 0) { MessageSend(vSubtask, "CM00453", "Configuration Management", "Component to be Deleted is currently opened for update.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } } } if (nRC >= zCURSOR_SET) { szCM_ViewName = GetStringFromAttribute(vActiveList, "W_MetaDef", "CM_ViewName"); nReferOI_Active = 0; if (GetViewByName(CM_View, szCM_ViewName + ".r", vZeidonCM, zLEVEL_SUBTASK) > 0) { // REFER OI of Meta exists - Check if there are Views to it nReferOI_Active = 1; nReferViewsActive = 0; lMOI_InstanceID = MiGetInstanceID_ForView(CM_View); nRC = DriverApplication.SfGetFirstNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); while (nRC > 0) { if (sbNamedView.substring(0, 5).compareTo("__CM.") == 0) // if ( zstrncmp( sbNamedView, "__CM.", 5 ) == 0 ) { nRC = DriverApplication.SfGetFirstNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK); while (nRC > 0) { if (sbTaskView.charAt(0) == 'r') // if ( zstrncmp( sbTaskView, "r", 1 ) == 0 ) { if (MiGetInstanceID_ForView(vWork2) == lMOI_InstanceID) { nReferViewsActive = 1; break; } } nRC = DriverApplication.SfGetNextNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK); } } if (nReferViewsActive == 1) { sbErrMsg.setLength(0); sbErrMsg.append("The Meta you are trying to delete,\n"); sbErrMsg.append(GetStringFromAttribute(vActiveMetas, "W_MetaDef", "Name")); sbErrMsg.append(", Type "); sbErrMsg.append(GetVariableFromAttribute(0, zTYPE_STRING, 125, vActiveMetas, "W_MetaType", "Type", "CM_Type", 0)); sbErrMsg.append( ",\nis being referenced by a Zeidon Tool.\nTo delete this meta close the other Zeidon Tool.\n"); MessageSend(vSubtask, "CM00454", "Configuration Management", sbErrMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return 0; } nRC = DriverApplication.SfGetNextNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK); } } } if (nReferOI_Active != 0 && nReferViewsActive == 0) { DropObjectInstance(CM_View); } else if (nReferOI_Active != 0) { DropView(CM_View); } // Determine fully contatenated file name for delete. fnGetDirectorySpec(vListView, sbFileSpec, nType); if (nWorkType == zSOURCE_VOR_META) { zltoxa(lMetaOI_ZKey, sbMetaOI_Name); } zstrcat(sbFileSpec, sbMetaOI_Name.toString()); zstrcat(sbFileSpec, SRC_CMOD[nWorkType].szOD_EXT); nRC = ActivateMetaOI_ByZKey(vSubtask, vMeta, vListView, nWorkType, zSINGLE | zLEVEL_APPLICATION, lMetaOI_ZKey, zCURRENT_OI); if (nRC < 0) { MessageSend(vSubtask, "CM00455", "Configuration Management", "Removing meta without deleting file.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); DeleteEntity(vLPLR, "W_MetaDef", zREPOS_NONE); return -1; } if (CheckExistenceOfEntity(vMeta, "Z_MetaDef") >= zCURSOR_SET) { if (CompareAttributeToInteger(vLPLR, "W_MetaDef", "UpdateInd", 3) == 0) { MessageSend(vSubtask, "CM00456", "Configuration Management", "Component to be Deleted has already been deleted.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); return -1; } SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nWorkType, ""); SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, ""); SetAttributeFromInteger(vLPLR, "W_MetaDef", "UpdateInd", 3); SetAttributeFromString(vLPLR, "W_MetaDef", "Desc", "*** Deleted ***"); SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nWorkType + 2000, ""); nRC = SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, ""); nRC2 = SetCursorFirstEntityByEntityCsr(vActiveList, "W_MetaDef", vLPLR, "W_MetaDef", "LPLR"); if (nRC2 >= zCURSOR_SET) { ExcludeEntity(vActiveList, "W_MetaDef", zREPOS_NONE); } if (nRC >= zCURSOR_SET) { ExcludeEntity(vLPLR, "W_MetaDef", zREPOS_NONE); } } else { if (SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE) < 0) { zstrcpy(sbErrMsg, "File "); zstrcat(sbErrMsg, sbFileSpec); zstrcat(sbErrMsg, "\nNot found - deleting entry from CM List"); MessageSend(vSubtask, "CM00457", "Configuration Management", sbErrMsg.toString(), zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); } nRC = SetCursorFirstEntityByEntityCsr(vActiveList, "W_MetaDef", vLPLR, "W_MetaDef", "LPLR"); if (nRC >= zCURSOR_SET) { ExcludeEntity(vActiveList, "W_MetaDef", zREPOS_NONE); } DeleteEntity(vLPLR, "W_MetaDef", zREPOS_PREV); if (nWorkType == zSOURCE_DIALOG_META || nWorkType == zSOURCE_LOD_META) { sbFileSpec.setLength(0); GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, sbMetaOI_Name); if (nWorkType == zSOURCE_DIALOG_META) { zstrcat(sbFileSpec, ".XWD"); } else { zstrcat(sbFileSpec, ".XOD"); // For LOD, also delete all the related VORs. This has to be // done by activating every VOR to see if it is for the deleted LOD. RetrieveViewForMetaList(vSubtask, vVOR_LPLR, zSOURCE_VOR_META); nRC = SetCursorFirstEntity(vVOR_LPLR, "W_MetaDef", ""); while (nRC >= zCURSOR_SET) { nRC = ActivateMetaOI(vSubtask, vVOR, vVOR_LPLR, zSOURCE_VOR_META, zSINGLE | zLEVEL_APPLICATION); if (nRC >= 0) { if (CompareAttributeToString(vVOR, "LOD", "Name", sbMetaOI_Name.toString()) == 0) { DropMetaOI(vSubtask, vVOR); nRC = DeleteMetaOI(vSubtask, vVOR_LPLR, zSOURCE_VOR_META); if (nRC >= 0) { SetCursorPrevEntity(vVOR_LPLR, "W_MetaDef", ""); } nRC = CheckExistenceOfEntity(vVOR_LPLR, "W_MetaDef"); } else { DropMetaOI(vSubtask, vVOR); nRC = SetCursorNextEntity(vVOR_LPLR, "W_MetaDef", ""); } } else { nRC = SetCursorNextEntity(vVOR_LPLR, "W_MetaDef", ""); } } } if (SysOpenFile(vVOR_LPLR, sbFileSpec.toString(), COREFILE_DELETE) < 0) { zstrcpy(sbErrMsg, "Corresponding Executable File "); zstrcat(sbErrMsg, sbFileSpec); zstrcat(sbErrMsg, " Not found."); MessageSend(vSubtask, "CM00458", "Configuration Management", sbErrMsg.toString(), zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); } } // if this is a Report we have to delete file XRP and for SironReports // files REP and XSQ too. if (nWorkType == zSOURCE_REPORT_META || nWorkType == zREFER_REPORT_META || nWorkType == zSOURCE_XSLT_META || nWorkType == zREFER_XSLT_META) { String szReportFile; sbFileSpec.setLength(0); GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, sbMetaOI_Name); szReportFile = sbFileSpec.toString(); // Save the name without extension because we have to // delete XSQ too for SironReports if (nWorkType == zSOURCE_REPORT_META || nWorkType == zREFER_REPORT_META) { zstrcat(sbFileSpec, ".XRP"); } else { zstrcat(sbFileSpec, ".XSL"); } if (SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE) < 0) { zstrcpy(sbErrMsg, "Corresponding Executable File "); zstrcat(sbErrMsg, sbFileSpec); zstrcat(sbErrMsg, " Not found."); MessageSend(vSubtask, "CM00458", "Configuration Management", sbErrMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0); } if (nWorkType == zSOURCE_REPORT_META || nWorkType == zREFER_REPORT_META) { // Try to delete the XSQ file zstrcpy(sbFileSpec, szReportFile); zstrcat(sbFileSpec, ".XSQ"); SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE); // We don't test the Returncode of // SysOpenFile, because we get an error // if the report is a zeidon report. // Try to delete the REP file // We first get the directory where we'll find the REP file if it exists GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "PgmSrcDir"); SysAppendcDirSep(sbFileSpec); zstrcat(sbFileSpec, sbMetaOI_Name); zstrcat(sbFileSpec, ".REP"); SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE); // We don't test the Returncode of // SysOpenFile, because we get an error // if the report is a zeidon report. } } } // If this is a Domain Group, remove all the subordinate Domain entries // from the LPLR list. if (nWorkType == zSOURCE_DOMAINGRP_META) { CreateViewFromViewForTask(vLPLR2, vLPLR, vSubtask); SetCursorFirstEntityByInteger(vLPLR2, "W_MetaType", "Type", zSOURCE_DOMAIN_META, ""); nRC = SetCursorFirstEntity(vLPLR2, "W_MetaDef", ""); while (nRC >= zCURSOR_SET) { if (CompareAttributeToAttribute(vLPLR2, "W_MetaDef", "GroupName", vMeta, "DomainGroup", "Name") == 0) { DeleteEntity(vLPLR2, "W_MetaDef", zREPOS_NONE); } nRC = SetCursorNextEntity(vLPLR2, "W_MetaDef", ""); } SetCursorFirstEntityByInteger(vLPLR2, "W_MetaType", "Type", zREFER_DOMAIN_META, ""); nRC = SetCursorFirstEntity(vLPLR2, "W_MetaDef", ""); while (nRC >= zCURSOR_SET) { if (CompareAttributeToAttribute(vLPLR2, "W_MetaDef", "GroupName", vMeta, "DomainGroup", "Name") == 0) { DeleteEntity(vLPLR2, "W_MetaDef", zREPOS_NONE); } nRC = SetCursorNextEntity(vLPLR2, "W_MetaDef", ""); } DropView(vLPLR2); } // If this is an Operation Group, remove all the subordinate Operation // entries from the LPLR list. if (nWorkType == zSOURCE_GOPGRP_META) { CreateViewFromViewForTask(vLPLR2, vLPLR, vSubtask); SetCursorFirstEntityByInteger(vLPLR2, "W_MetaType", "Type", zSOURCE_GO_META, ""); nRC = SetCursorFirstEntity(vLPLR2, "W_MetaDef", ""); while (nRC >= zCURSOR_SET) { if (CompareAttributeToAttribute(vLPLR2, "W_MetaDef", "GroupName", vMeta, "GlobalOperationGroup", "Name") == 0) { DeleteEntity(vLPLR2, "W_MetaDef", zREPOS_NONE); } nRC = SetCursorNextEntity(vLPLR2, "W_MetaDef", ""); } SetCursorFirstEntityByInteger(vLPLR2, "W_MetaType", "Type", zREFER_GO_META, ""); nRC = SetCursorFirstEntity(vLPLR2, "W_MetaDef", ""); while (nRC >= zCURSOR_SET) { if (CompareAttributeToAttribute(vLPLR2, "W_MetaDef", "GroupName", vMeta, "GlobalOperationGroup", "Name") == 0) { DeleteEntity(vLPLR2, "W_MetaDef", zREPOS_NONE); } nRC = SetCursorNextEntity(vLPLR2, "W_MetaDef", ""); } DropView(vLPLR2); } if (CheckExistenceOfEntity(vMeta, "Z_MetaDef") >= zCURSOR_SET) { DeleteEntity(vMeta, SRC_CMOD[nWorkType].szOD_ROOT, zREPOS_NONE); CommitOI_ToFile(vMeta, sbFileSpec.toString(), zASCII | zINCREMENTAL); } DropObjectInstance(vMeta); if (CommitLPLR(vLPLR) == 0) { DropView(vLPLR); return 0; } DropView(vLPLR); return -1; }
From source file:com.clark.func.Functions.java
/** * Parses the Windows dir response last line * /*from w w w . j a v a 2 s. c o m*/ * @param line * the line to parse * @param path * the path that was sent * @return the number of bytes * @throws IOException * if an error occurs */ static long parseDir(String line, String path) throws IOException { // read from the end of the line to find the last numeric // character on the line, then continue until we find the first // non-numeric character, and everything between that and the last // numeric character inclusive is our free space bytes count int bytesStart = 0; int bytesEnd = 0; int j = line.length() - 1; innerLoop1: while (j >= 0) { char c = line.charAt(j); if (Character.isDigit(c)) { // found the last numeric character, this is the end of // the free space bytes count bytesEnd = j + 1; break innerLoop1; } j--; } innerLoop2: while (j >= 0) { char c = line.charAt(j); if (!Character.isDigit(c) && c != ',' && c != '.') { // found the next non-numeric character, this is the // beginning of the free space bytes count bytesStart = j + 1; break innerLoop2; } j--; } if (j < 0) { throw new IOException("Command line 'dir /-c' did not return valid info " + "for path '" + path + "'"); } // remove commas and dots in the bytes count StringBuilder buf = new StringBuilder(line.substring(bytesStart, bytesEnd)); for (int k = 0; k < buf.length(); k++) { if (buf.charAt(k) == ',' || buf.charAt(k) == '.') { buf.deleteCharAt(k--); } } return parseBytes(buf.toString(), path); }