public void nextMode() {
   int nextOrd = mode.ordinal() + 1;
   if (nextOrd >= MODE.values().length) {
     nextOrd = 0;
   }
   mode = MODE.values()[nextOrd];
   System.out.println("Displaying " + mode);
 }
 public void prevMode() {
   int prevOrd = mode.ordinal() - 1;
   if (prevOrd < 0) {
     prevOrd = MODE.values().length - 1;
   }
   mode = MODE.values()[prevOrd];
   System.out.println("Displaying " + mode);
 }
 public static MODE findById(Integer id) {
   for (final MODE aMode : MODE.values()) {
     if (aMode.getId() == id) {
       return aMode;
     }
   }
   return null;
 }
Exemplo n.º 4
0
  public void decrementMode() {
    if (mode == MODE.SPIRAL) resetSpiral();

    int num = mode.ordinal();
    num--;

    if (num < 0) num = MODE.values().length - 1;

    mode = MODE.values()[num];
  }
Exemplo n.º 5
0
  public void incrementMode() {
    if (mode == MODE.SPIRAL) resetSpiral();

    int num = mode.ordinal();
    num++;

    if (num >= MODE.values().length) num = 0;

    mode = MODE.values()[num];
  }
Exemplo n.º 6
0
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    storage.readFromNBT(nbt);

    laserSat.readFromNBT(nbt.getCompoundTag("laser"));

    /*NBTTagList tagList = nbt.getTagList("Inventory");
    for (int i = 0; i < tagList.tagCount(); i++) {
    	NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
    	byte slot = tag.getByte("Slot");
    	if (slot >= 0 && slot < invBuffer.length) {
    		invBuffer[slot] = ItemStack.loadItemStackFromNBT(tag);
    	}
    }*/
    if (nbt.hasKey("GlassPane")) {
      NBTTagCompound tag = nbt.getCompoundTag("GlassPane");
      glassPanel = ItemStack.loadItemStackFromNBT(tag);
    }

    laserX = nbt.getInteger("laserX");
    laserZ = nbt.getInteger("laserZ");
    mode = MODE.values()[nbt.getByte("mode")];

    if (mode == MODE.SPIRAL) {
      xCenter = nbt.getInteger("CenterX");
      yCenter = nbt.getInteger("CenterY");
      radius = nbt.getInteger("radius");
      numSteps = nbt.getInteger("numSteps");
      prevDir = ForgeDirection.values()[nbt.getInteger("prevDir")];
    }
  }
Exemplo n.º 7
0
 /*
  * ID 0: client changed xcoord in interface
  * ID 1: client changed ycoord in interface
  * ID 2: sync whether the machine is running
  * ID 3: sync Mode
  * ID 4: jam reset
  */
 @Override
 public void writeDataToNetwork(ByteBuf out, byte id) {
   if (id == 0) out.writeInt(this.laserX);
   else if (id == 1) out.writeInt(this.laserZ);
   else if (id == 2) out.writeBoolean(isRunning);
   else if (id == 3) out.writeInt(mode.ordinal());
 }
Exemplo n.º 8
0
  @Override
  public void useNetworkData(EntityPlayer player, Side side, byte id, NBTTagCompound nbt) {
    if (id == 0) {
      this.laserX = nbt.getInteger("laserX");
      finished = false;

      if (mode == MODE.SPIRAL) resetSpiral();
    } else if (id == 1) {
      this.laserZ = nbt.getInteger("laserZ");
      finished = false;
      if (mode == MODE.SPIRAL) resetSpiral();
    } else if (id == 2) this.isRunning = nbt.getBoolean("isRunning");
    else if (id == 3 && !isRunning()) this.mode = MODE.values()[nbt.getInteger("mode")];
    else if (id == 4) this.attempUnjam();
  }
  public void execute(Connection conn) throws ProtocolException {
    int i = 0;
    try {
      for (Command command : list) {
        command.execute(conn);

        i++;

        if (mode.equals(MODE.LIST_OK)) conn.send(new ProtocolListOK());
      }
      conn.send(new ProtocolOK());
    } catch (ProtocolException e) {
      // Set line on which the execution failed
      e.setLine(i);
      throw e;
    }
  }
Exemplo n.º 10
0
  @Override
  public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    storage.writeToNBT(nbt);

    NBTTagCompound laser = new NBTTagCompound();
    laserSat.writeToNBT(laser);

    nbt.setTag("laser", laser);

    NBTTagList list = new NBTTagList();
    NBTTagList itemList = new NBTTagList();
    /*for(int i = 0; i < invBuffer.length; i++)
    {
    	ItemStack stack = invBuffer[i];
    	if(stack != null) {
    		NBTTagCompound tag = new NBTTagCompound();
    		tag.setByte("Slot", (byte)(i));
    		stack.writeToNBT(tag);
    		itemList.appendTag(tag);
    	}
    }
    nbt.setTag("InventoryBuffer", itemList);*/

    if (glassPanel != null) {
      NBTTagCompound tag = new NBTTagCompound();
      glassPanel.writeToNBT(tag);
      nbt.setTag("GlassPane", tag);
    }

    nbt.setInteger("laserX", laserX);
    nbt.setInteger("laserZ", laserZ);
    nbt.setByte("mode", (byte) mode.ordinal());

    if (mode == MODE.SPIRAL) {
      nbt.setInteger("CenterX", xCenter);
      nbt.setInteger("CenterY", yCenter);
      nbt.setInteger("radius", radius);
      nbt.setInteger("numSteps", numSteps);
      nbt.setInteger("prevDir", prevDir.ordinal());
    }
  }
Exemplo n.º 11
0
 public String getESRCode() {
   return MODE.values()[checkZero(get(CODE))].toString();
 }
Exemplo n.º 12
0
  /** Der Konstruktor liest eine ESR-Zeile ein und konstruiert daraus den Datensatz. */
  public ESRRecord(final String file, final String codeline) {
    super.create(null);
    Mandant m;
    Rechnung rn = null;
    String mandantID;
    REJECT rejectCode;

    String[] vals = new String[11];
    vals[0] = new TimeTool().toString(TimeTool.DATE_COMPACT);
    vals[10] = file;

    rejectCode = REJECT.OK;

    // Code/Modus.
    MODE mode = MODE.Unbekannt;
    String smd = codeline.substring(0, 3);
    if (smd.equals("002")) { // $NON-NLS-1$
      mode = MODE.Gutschrift_edv;
    } else if (smd.equals("012")) { // $NON-NLS-1$
      mode = MODE.Gutschrift_Schalter;
    } else if (smd.equals("005")) { // $NON-NLS-1$
      mode = MODE.Storno_edv;
    } else if (smd.equals("015")) { // $NON-NLS-1$
      mode = MODE.Storno_Schalter;
    } else if (smd.equals("008")) { // $NON-NLS-1$
      mode = MODE.Korrektur_edv;
    } else if (smd.equals("018")) { // $NON-NLS-1$
      mode = MODE.Korrektur_Schalter;
    } else if (smd.equals("999")) { // $NON-NLS-1$
      mode = MODE.Summenrecord;
    }
    vals[5] = Integer.toString(mode.ordinal());

    // Daten parsen. Der ESR-Record liefert 6-stellige Daten, wir wollen 8-stellige
    String prefix = vals[0].substring(0, 2);
    // TODO Das funktioniert nur bis ins Jahr 2099 :-)
    TimeTool dat = new TimeTool(prefix + codeline.substring(59, 65));
    vals[1] = dat.toString(TimeTool.DATE_GER);
    dat.set(prefix + codeline.substring(65, 71));
    vals[2] = dat.toString(TimeTool.DATE_GER);
    dat.set(prefix + codeline.substring(71, 77));
    vals[3] = (dat.toString(TimeTool.DATE_GER));

    if (mode.equals(MODE.Summenrecord)) {
      // Betrag (führende Nullen entfernen)
      vals[4] =
          Integer.toString(Integer.parseInt(codeline.substring(39, 51).trim())); // Totalbetrag
      // 12-stellig
    } else {
      vals[4] =
          Integer.toString(Integer.parseInt(codeline.substring(39, 49).trim())); // Zeilenbetrag
      // 10-stellig
      String esrline = codeline.substring(12, 39);

      // Von der RechnungsNummer führende Nullen wegbringen
      int rnnr = Integer.parseInt(esrline.substring(POSITION_RN_NR, 26));
      Query<Rechnung> qbe_r = new Query<Rechnung>(Rechnung.class);
      String rnid =
          qbe_r.findSingle("RnNummer", "=", Integer.toString(rnnr)); // $NON-NLS-1$ //$NON-NLS-2$
      if (rnid == null) {
        rejectCode = REJECT.RN_NUMMER;
        vals[6] = ""; // $NON-NLS-1$
        mandantID = ""; // $NON-NLS-1$
      } else {
        vals[6] = rnid;
        rn = Rechnung.load(rnid);
        if (rn == null) {
          rejectCode = REJECT.RN_NUMMER;
          vals[6] = ""; // $NON-NLS-1$
          mandantID = ""; // $NON-NLS-1$
        } else {
          m = rn.getMandant();
          if (m == null) {
            rejectCode = REJECT.MANDANT;
            vals[6] = ""; // $NON-NLS-1$
            mandantID = ""; // $NON-NLS-1$
          } else {
            mandantID = m.getId();
          }
        }
      }
      String PatNr = esrline.substring(POSITION_PAT_NR, POSITION_RN_NR);
      long patnr = Long.parseLong(PatNr); // führende Nullen wegbringen
      String PatID =
          new Query<Patient>(Patient.class)
              .findSingle("PatientNr", "=", Long.toString(patnr)); // $NON-NLS-1$ //$NON-NLS-2$
      if (PatID == null) {
        if (rejectCode == REJECT.OK) {
          rejectCode = REJECT.PAT_NUMMER;
        }
        vals[7] = ""; // $NON-NLS-1$
      } else if ((rn != null) && (!rn.getFall().getPatient().getId().equals(PatID))) {
        if (rejectCode == REJECT.OK) {
          rejectCode = REJECT.PAT_FALSCH;
        }
        vals[7] = ""; // $NON-NLS-1$
      } else {

        vals[7] = PatID;
      }
      vals[8] = mandantID;
    }
    vals[9] = Integer.toString(rejectCode.ordinal());
    set(
        new String[] {
          "Datum",
          "Eingelesen",
          "Verarbeitet",
          "Gutgeschrieben", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          "BetragInRp",
          CODE,
          RECHNUNGS_ID,
          PATIENT_ID,
          MANDANT_ID,
          FLD_REJECT_CODE,
          "File"
        },
        vals); //$NON-NLS-1$ //$NON-NLS-2$
  }
Exemplo n.º 13
0
 public MODE getTyp() {
   int m = getInt(CODE);
   MODE ret = MODE.values()[m];
   return ret;
 }
Exemplo n.º 14
0
  /**
   * @param queryResult
   * @return
   */
  public static QueryResultDTO buildTableResult(
      QueryResult<?> queryResult,
      MODE mode,
      Map<String, TrivialManualActivityDTO> trivialManualActivityDetails,
      List<String> extraColumns) {
    List<ActivityInstanceDTO> list = new ArrayList<ActivityInstanceDTO>();
    List<CriticalityCategory> criticalityConfigurations =
        CriticalityUtils.getCriticalityConfiguration();

    ModelCache modelCache = ModelCache.findModelCache();
    QueryResultDTO resultDTO = new QueryResultDTO();
    if (null != queryResult) {
      for (Object object : queryResult) {
        if (object instanceof ActivityInstance) {
          ActivityInstance ai = (ActivityInstance) object;
          ActivityInstanceDTO dto;

          if (ActivityInstanceUtils.isTrivialManualActivity(ai)) {
            TrivialActivityInstanceDTO trivialDto =
                DTOBuilder.build(ai, TrivialActivityInstanceDTO.class);
            trivialDto.trivial = true;

            if (null != trivialManualActivityDetails
                && trivialManualActivityDetails.keySet().contains(String.valueOf(ai.getOID()))) {
              TrivialManualActivityDTO tivialManualActivity =
                  trivialManualActivityDetails.get(String.valueOf(ai.getOID()));
              trivialDto.dataMappings = tivialManualActivity.dataMappings;
              trivialDto.inOutData = tivialManualActivity.inOutData;
            }

            dto = trivialDto;
          } else {
            dto = DTOBuilder.build(ai, ActivityInstanceDTO.class);
          }

          dto.auxillary = isAuxiliaryActivity(ai.getActivity());
          dto.duration = ActivityInstanceUtils.getDuration(ai);
          dto.assignedTo = getAssignedToLabel(ai);
          dto.criticality = populateCriticalityDTO(criticalityConfigurations, ai);
          dto.priority = DTOBuilder.build(ai, PriorityDTO.class);
          dto.status = DTOBuilder.build(ai, StatusDTO.class);
          dto.status.label = ActivityInstanceUtils.getActivityStateLabel(ai);
          dto.descriptorValues = getProcessDescriptors(modelCache, ai);
          dto.activatable = findIfActivatable(ai);
          dto.relocationEligible =
              org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils
                  .isRelocationEligible(ai);
          dto.benchmark = getBenchmarkForActivity(ai);

          List<Note> notes =
              org.eclipse.stardust.ui.web.viewscommon.utils.ProcessInstanceUtils.getNotes(
                  ai.getProcessInstance());
          if (null != notes) {
            dto.notesCount = notes.size();
          }

          if (CollectionUtils.isNotEmpty(extraColumns)
              && extraColumns.contains(Constants.RESUBMISSION_TIME)) {
            Date resubmissionDate =
                org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils
                    .getResubmissionDate(ai);
            if (null != resubmissionDate) {
              dto.resubmissionTime = resubmissionDate.getTime();
            }
          }
          ProcessDefinition processDefinition =
              ProcessDefinitionUtils.getProcessDefinition(
                  ai.getModelOID(), ai.getProcessDefinitionId());
          dto.processInstance.supportsProcessAttachments =
              ProcessDefinitionUtils.supportsProcessAttachments(processDefinition);

          if (mode.equals(MODE.ACTIVITY_TABLE)) {
            dto.completedBy = ActivityInstanceUtils.getPerformedByName(ai);
            dto.participantPerformer = getParticipantPerformer(ai);
            dto.abortActivity = !dto.isCaseInstance && isAbortable(ai);
            dto.delegable = isDelegable(ai);
            dto.abortProcess = ProcessInstanceUtils.isAbortable(ai.getProcessInstance());

          } else {
            dto.lastPerformer = getLastPerformer(ai, UserUtils.getDefaultUserNameDisplayFormat());
            if (!dto.defaultCaseActivity) {
              dto.abortActivity = isAbortable(ai);
              dto.delegable = isDelegable(ai);
            }
          }
          dto.defaultCaseActivity = ActivityInstanceUtils.isDefaultCaseActivity(ai);
          dto.isCaseInstance = ai.getProcessInstance().isCaseProcessInstance();
          if (dto.defaultCaseActivity) {
            dto.activity.name = getCaseName(ai);
          }
          list.add(dto);
        }
      }
      resultDTO.totalCount = queryResult.getTotalCount();
    }
    resultDTO.list = list;
    return resultDTO;
  }